| 1 | |
package com.ctrip.framework.apollo.common.controller; |
| 2 | |
|
| 3 | |
import java.util.List; |
| 4 | |
|
| 5 | |
import org.springframework.context.annotation.Configuration; |
| 6 | |
import org.springframework.data.domain.PageRequest; |
| 7 | |
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; |
| 8 | |
import org.springframework.http.MediaType; |
| 9 | |
import org.springframework.web.method.support.HandlerMethodArgumentResolver; |
| 10 | |
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; |
| 11 | |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
| 12 | |
|
| 13 | |
@Configuration |
| 14 | 0 | public class WebMvcConfig extends WebMvcConfigurerAdapter { |
| 15 | |
|
| 16 | |
@Override |
| 17 | |
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { |
| 18 | 0 | PageableHandlerMethodArgumentResolver pageResolver = |
| 19 | |
new PageableHandlerMethodArgumentResolver(); |
| 20 | 0 | pageResolver.setFallbackPageable(new PageRequest(0, 10)); |
| 21 | |
|
| 22 | 0 | argumentResolvers.add(pageResolver); |
| 23 | 0 | } |
| 24 | |
|
| 25 | |
@Override |
| 26 | |
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { |
| 27 | 0 | configurer.favorPathExtension(false); |
| 28 | 0 | configurer.ignoreAcceptHeader(true).defaultContentType(MediaType.APPLICATION_JSON); |
| 29 | 0 | } |
| 30 | |
|
| 31 | |
} |