當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。