public class MyWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[0];
}
//post乱码
@Override
protected Filter[] getServletFilters() {
return new Filter[]{
new CharacterEncodingFilter()
};
}
//JavaConfig类
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[]{
MyMvcConfig.class
};
}
//拦截
@Override
protected String[] getServletMappings() {
return new String[]{ "/" };
}
}
@Configuration
@EnableWebMvc
@ComponentScan("这里填写自己要扫描的包")
public class MyMvcConfig{
}
720750-20171220154321475-947231047.png (54.35 KB, 下载次数: 28)
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |