From eb3453240c4c99c4d0bdcff50655ae5ac9b35db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E9=99=90=E8=B6=85=E9=A2=91?= <1029559041@qq.com> Date: Fri, 15 Sep 2017 15:35:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20javax.servlet=20jar?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 +-- src/main/java/org/pqh/config/WebConfig.java | 47 +++++++++------------ src/main/java/org/pqh/util/Log4jUtil.java | 8 ++++ 3 files changed, 33 insertions(+), 29 deletions(-) create mode 100644 src/main/java/org/pqh/util/Log4jUtil.java diff --git a/pom.xml b/pom.xml index 8856fd2..9916f45 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ UTF-8 1.8 6.0.6 + 4.3.10.RELEASE @@ -22,19 +23,19 @@ org.springframework spring-web - RELEASE + ${spring.version} org.springframework spring-webmvc - RELEASE + ${spring.version} org.springframework spring-orm - RELEASE + ${spring.version} diff --git a/src/main/java/org/pqh/config/WebConfig.java b/src/main/java/org/pqh/config/WebConfig.java index 64d649d..2dbda22 100644 --- a/src/main/java/org/pqh/config/WebConfig.java +++ b/src/main/java/org/pqh/config/WebConfig.java @@ -1,46 +1,41 @@ package org.pqh.config; -import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.filter.CharacterEncodingFilter; +import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; +import javax.servlet.Filter; /** * Created by reborn on 2017/7/28. */ -public class WebConfig implements WebApplicationInitializer { +public class WebConfig extends AbstractAnnotationConfigDispatcherServletInitializer { private String encoding ="UTF-8"; + @Override + protected Filter[] getServletFilters() { + return new Filter[]{new CharacterEncodingFilter(encoding)}; + } -// @Override -// protected Filter[] getServletFilters() { -// org.springframework.web.SpringServletContainerInitializer -// org.springframework.web.SpringServletContainerInitializer -// return new Filter[]{new CharacterEncodingFilter(encoding)}; -// } -// -// @Override -// protected String[] getServletMappings() { -// return new String[]{"/"}; -// } -// -// @Override -// protected Class[] getRootConfigClasses() { -// return new Class[0]; -// } -// -// @Override -// protected Class[] getServletConfigClasses() { -// return new Class[]{SpringConfig.class}; -// } + @Override + protected String[] getServletMappings() { + return new String[]{"/"}; + } @Override - public void onStartup(ServletContext servletContext) throws ServletException { + protected Class[] getRootConfigClasses() { + return new Class[0]; + } + @Override + protected Class[] getServletConfigClasses() { + return new Class[]{SpringConfig.class}; } + + + } diff --git a/src/main/java/org/pqh/util/Log4jUtil.java b/src/main/java/org/pqh/util/Log4jUtil.java new file mode 100644 index 0000000..ee908f2 --- /dev/null +++ b/src/main/java/org/pqh/util/Log4jUtil.java @@ -0,0 +1,8 @@ +package org.pqh.util; + +/** + * Created by reborn on 2017/8/8. + */ +public class Log4jUtil { + +}