|
|
|
@ -3,7 +3,8 @@ package org.pqh.config; |
|
|
|
|
import org.springframework.web.filter.CharacterEncodingFilter; |
|
|
|
|
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; |
|
|
|
|
|
|
|
|
|
import javax.servlet.Filter; |
|
|
|
|
import javax.servlet.*; |
|
|
|
|
import java.util.EnumSet; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Created by reborn on 2017/7/28. |
|
|
|
@ -13,12 +14,6 @@ public class WebConfig extends AbstractAnnotationConfigDispatcherServletInitiali |
|
|
|
|
|
|
|
|
|
private String encoding ="UTF-8"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected Filter[] getServletFilters() { |
|
|
|
|
return new Filter[]{new CharacterEncodingFilter(encoding)}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String[] getServletMappings() { |
|
|
|
|
return new String[]{"/"}; |
|
|
|
@ -34,8 +29,13 @@ public class WebConfig extends AbstractAnnotationConfigDispatcherServletInitiali |
|
|
|
|
return new Class[]{SpringConfig.class}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onStartup(ServletContext servletContext) throws ServletException { |
|
|
|
|
super.onStartup(servletContext); |
|
|
|
|
FilterRegistration.Dynamic dynamic=super.registerServletFilter(servletContext,new CharacterEncodingFilter(encoding)); |
|
|
|
|
dynamic.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST),true,"/*"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|