(118) - Add java-config(零配置) 的支持
parent
d34b48138c
commit
4d94ac10c6
|
@ -0,0 +1,40 @@
|
|||
package com.monkeyk.sos.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.*;
|
||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
import org.springframework.web.servlet.view.JstlView;
|
||||
|
||||
/**
|
||||
* 2016/4/3
|
||||
* <p/>
|
||||
* Replace mkk-servlet.xml
|
||||
*
|
||||
* @author Shengzhao Li
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
public class MkkWebMvcConfigurer extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
||||
configurer.enable();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void configureViewResolvers(ViewResolverRegistry registry) {
|
||||
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
|
||||
viewResolver.setViewClass(JstlView.class);
|
||||
viewResolver.setPrefix("/WEB-INF/jsp/");
|
||||
viewResolver.setSuffix(".jsp");
|
||||
registry.viewResolver(viewResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/index.jsp*").addResourceLocations("/index.jsp");
|
||||
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
|
||||
}
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@ public class ServletInitializer extends AbstractAnnotationConfigDispatcherServle
|
|||
|
||||
@Override
|
||||
protected Class<?>[] getServletConfigClasses() {
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
return new Class[]{MkkWebMvcConfigurer.class};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue