本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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));
}
示例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());
}
};
}
示例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);
}
示例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);
}
示例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"));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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)));
}