当前位置: 首页>>代码示例>>Java>>正文


Java PageableHandlerMethodArgumentResolver类代码示例

本文整理汇总了Java中org.springframework.data.web.PageableHandlerMethodArgumentResolver的典型用法代码示例。如果您正苦于以下问题:Java PageableHandlerMethodArgumentResolver类的具体用法?Java PageableHandlerMethodArgumentResolver怎么用?Java PageableHandlerMethodArgumentResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PageableHandlerMethodArgumentResolver类属于org.springframework.data.web包,在下文中一共展示了PageableHandlerMethodArgumentResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Before
    public void setup() {
        this.mockMvc = standaloneSetup(new PostController(postService, posts, comments))
            .setCustomArgumentResolvers(
                new PageableHandlerMethodArgumentResolver()
            )
//            .setViewResolvers(new ViewResolver() {
//                @Override
//                public org.springframework.web.servlet.View resolveViewName(String viewName, Locale locale) 
//                    throws Exception {
//                    return new MappingJackson2JsonView(objectMapper);
//                }
//            })
            
            .setMessageConverters(
                new MappingJackson2HttpMessageConverter(objectMapper)
            )

            .alwaysDo(print())
            .apply(springSecurity(springSecurityFilterChain))
            .build();
    }
 
开发者ID:hantsy,项目名称:spring-microservice-sample,代码行数:23,代码来源:ControllerTest.java

示例2: addArgumentResolvers

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
	Sort defaultSort = new Sort(new Sort.Order(Sort.Direction.ASC, "id"));
	Pageable defaultPage = new PageRequest(0, 10, defaultSort);

	SortHandlerMethodArgumentResolver sortHandlerMethodArgumentResolver = new SortHandlerMethodArgumentResolver();
	sortHandlerMethodArgumentResolver.setSortParameter("sort");
	sortHandlerMethodArgumentResolver.setFallbackSort(defaultSort);

	PageableHandlerMethodArgumentResolver pageableResolver = new PageableHandlerMethodArgumentResolver();
	pageableResolver.setMaxPageSize(100);
	pageableResolver.setOneIndexedParameters(false);
	pageableResolver.setPageParameterName("page");
	pageableResolver.setSizeParameterName("size");
	pageableResolver.setFallbackPageable(defaultPage);

	argumentResolvers.add(sortHandlerMethodArgumentResolver);
	argumentResolvers.add(pageableResolver);
}
 
开发者ID:shilongdai,项目名称:bookManager,代码行数:20,代码来源:ServletApplicationContextConfig.java

示例3: testDefaultRepositoryConfiguration

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Test
public void testDefaultRepositoryConfiguration() throws Exception {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.setServletContext(new MockServletContext());
	this.context.register(TestConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class,
			JpaRepositoriesAutoConfiguration.class,
			SpringDataWebAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	assertThat(this.context.getBean(CityRepository.class)).isNotNull();
	assertThat(this.context.getBean(PageableHandlerMethodArgumentResolver.class))
			.isNotNull();
	assertThat(this.context.getBean(FormattingConversionService.class)
			.canConvert(Long.class, City.class)).isTrue();
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:18,代码来源:JpaWebAutoConfigurationTests.java

示例4: testDefaultRepositoryConfiguration

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Test
public void testDefaultRepositoryConfiguration() throws Exception {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.setServletContext(new MockServletContext());
	this.context.register(TestConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class,
			JpaRepositoriesAutoConfiguration.class,
			SpringDataWebAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	assertNotNull(this.context.getBean(CityRepository.class));
	assertNotNull(this.context.getBean(PageableHandlerMethodArgumentResolver.class));
	assertTrue(this.context.getBean(FormattingConversionService.class)
			.canConvert(Long.class, City.class));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:JpaWebAutoConfigurationTests.java

示例5: mvcViewConfigurer

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Bean
public WebMvcConfigurerAdapter mvcViewConfigurer() {

	return new WebMvcConfigurerAdapter() {

		@Override
		public void addViewControllers(ViewControllerRegistry registry) {

			registry.addViewController("/").setViewName("search");
			registry.addViewController("/monitor").setViewName("monitor");
		}

		@Override
		public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
			argumentResolvers.add(new PageableHandlerMethodArgumentResolver());
		}
	};
}
 
开发者ID:christophstrobl,项目名称:spring-data-solr-showcase,代码行数:19,代码来源:WebContext.java

示例6: setUp

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Before
public void setUp() throws GeoLocationException {

	final ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver();
	final StaticApplicationContext applicationContext = new StaticApplicationContext();
	applicationContext.registerBeanDefinition("solrController",
			new RootBeanDefinition(SolrController.class, null, null));
	exceptionResolver.setApplicationContext(applicationContext);
	exceptionResolver.afterPropertiesSet();

	mockProductService = mock(ProductService.class);

	String badLocation = "35.453487-97.5184727";
	when(mockProductService.getProductsByLocation(badLocation)).thenThrow(new GeoLocationException());

	solrController = new SolrController(mockProductService);
	mockMvc = MockMvcBuilders.standaloneSetup(solrController)
			.setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver())
			.setHandlerExceptionResolvers(exceptionResolver).build();

	product = createProduct(1000);
	when(mockProductService.getProduct(PRODUCT_ID)).thenReturn(product);

	allProducts = createProductList(10);
	when(mockProductService.getProducts()).thenReturn(allProducts);

}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:28,代码来源:SolrProductControllerTests.java

示例7: addArgumentResolvers

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
  PageableHandlerMethodArgumentResolver pageResolver =
          new PageableHandlerMethodArgumentResolver();
  pageResolver.setFallbackPageable(new PageRequest(0, 10));

  argumentResolvers.add(pageResolver);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:9,代码来源:WebMvcConfig.java

示例8: getListOfWorkflows

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
/**
 * Get the full list of workflows
 * TODO: Mock the repository and test model attributes
 */
@Test
public void getListOfWorkflows() throws Exception {

    // Mock controller/MVC
    WorkflowController workflowController = new WorkflowController(
            Mockito.mock(WorkflowFormValidator.class),
            Mockito.mock(WorkflowService.class),
            Mockito.mock(GraphVizService.class));

    // Lots of hassle to make Spring Data Pageable work
    PageableHandlerMethodArgumentResolver pageableArgumentResolver =
            new PageableHandlerMethodArgumentResolver();
    InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
    viewResolver.setPrefix("/src/main/resources/templates");
    viewResolver.setSuffix(".html");
    MockMvc mockMvc = MockMvcBuilders
            .standaloneSetup(workflowController)
            .setCustomArgumentResolvers(pageableArgumentResolver)
            .setViewResolvers(viewResolver)
            .build();

    // Simple test to check the view
    mockMvc.perform(get("/workflows"))
            .andExpect(status().isOk())
            .andExpect(view().name("workflows"));

}
 
开发者ID:common-workflow-language,项目名称:cwlviewer,代码行数:32,代码来源:WorkflowControllerTest.java

示例9: addArgumentResolvers

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
    PageableHandlerMethodArgumentResolver resolver = new PageableHandlerMethodArgumentResolver();
    resolver.setOneIndexedParameters(true);
    resolver.setFallbackPageable(new PageRequest(0, 10));
    argumentResolvers.add(resolver);
    super.addArgumentResolvers(argumentResolvers);
}
 
开发者ID:nonocast,项目名称:todolist,代码行数:9,代码来源:WebConfig.java

示例10: addArgumentResolvers

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {

	PageableHandlerMethodArgumentResolver pageableHandlerMethodArgumentResolver = new PageableHandlerMethodArgumentResolver();
	pageableHandlerMethodArgumentResolver.setMaxPageSize(20);
	pageableHandlerMethodArgumentResolver
			.setFallbackPageable(new PageRequest(0, 20, new Sort(Direction.DESC, "dateCreated")));
	argumentResolvers.add(pageableHandlerMethodArgumentResolver);
}
 
开发者ID:ksambhav,项目名称:trueyes,代码行数:10,代码来源:CoreWebConfiguration.java

示例11: addArgumentResolvers

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
  PageableHandlerMethodArgumentResolver resolver = new PageableHandlerMethodArgumentResolver();
  resolver.setFallbackPageable(new PageRequest(
      Pagination.DEFAULT_PAGE_NUMBER,
      Pagination.NO_PAGINATION));
  argumentResolvers.add(resolver);
  super.addArgumentResolvers(argumentResolvers);
}
 
开发者ID:OpenLMIS,项目名称:openlmis-template-service,代码行数:10,代码来源:CustomWebMvcConfigurerAdapter.java

示例12: webSupportIsAutoConfiguredInWebApplicationContexts

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Test
public void webSupportIsAutoConfiguredInWebApplicationContexts() {
	this.context = new AnnotationConfigWebApplicationContext();
	((AnnotationConfigWebApplicationContext) this.context)
			.register(SpringDataWebAutoConfiguration.class);
	this.context.refresh();
	((AnnotationConfigWebApplicationContext) this.context)
			.setServletContext(new MockServletContext());
	Map<String, PageableHandlerMethodArgumentResolver> beans = this.context
			.getBeansOfType(PageableHandlerMethodArgumentResolver.class);
	assertThat(beans).hasSize(1);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:SpringDataWebAutoConfigurationTests.java

示例13: autoConfigurationBacksOffInNonWebApplicationContexts

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Test
public void autoConfigurationBacksOffInNonWebApplicationContexts() {
	this.context = new AnnotationConfigApplicationContext();
	((AnnotationConfigApplicationContext) this.context)
			.register(SpringDataWebAutoConfiguration.class);
	this.context.refresh();
	Map<String, PageableHandlerMethodArgumentResolver> beans = this.context
			.getBeansOfType(PageableHandlerMethodArgumentResolver.class);
	assertThat(beans).isEmpty();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:SpringDataWebAutoConfigurationTests.java

示例14: pageableResolver

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Bean
public PageableHandlerMethodArgumentResolver pageableResolver() {
	PageableHandlerMethodArgumentResolver pageableHandlerMethodArgumentResolver = new PageableHandlerMethodArgumentResolver(sortResolver());
	pageableHandlerMethodArgumentResolver.setPageParameterName("page");
	pageableHandlerMethodArgumentResolver.setOneIndexedParameters(true);
	pageableHandlerMethodArgumentResolver.setSizeParameterName("limit");
	return pageableHandlerMethodArgumentResolver;
}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:9,代码来源:WebConfiguration.java

示例15: webSupportIsAutoConfiguredInWebApplicationContexts

import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //导入依赖的package包/类
@Test
public void webSupportIsAutoConfiguredInWebApplicationContexts() {
	this.context = new AnnotationConfigWebApplicationContext();
	((AnnotationConfigWebApplicationContext) this.context)
			.register(SpringDataWebAutoConfiguration.class);
	this.context.refresh();
	((AnnotationConfigWebApplicationContext) this.context)
			.setServletContext(new MockServletContext());
	Map<String, PageableHandlerMethodArgumentResolver> beans = this.context
			.getBeansOfType(PageableHandlerMethodArgumentResolver.class);
	assertThat(beans.size(), is(equalTo(1)));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:13,代码来源:SpringDataWebAutoConfigurationTests.java


注:本文中的org.springframework.data.web.PageableHandlerMethodArgumentResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。