From 3e457fe06bec2cea54825d4de2ee414bcd168040 Mon Sep 17 00:00:00 2001 From: shuzheng <469741414@qq.com> Date: Sun, 2 Jul 2017 23:27:50 +0800 Subject: [PATCH] servlet 3.0 --- .../rpc/service/impl/UpmsApiServiceImpl.java | 2 +- zheng-upms/zheng-upms-server/pom.xml | 4 +- .../upms/server/CharacterEncodingFilter.java | 22 ++++++++++ .../com/zheng/upms/server/ShiroFilter.java | 20 ++++++++++ .../src/main/webapp/WEB-INF/web.xml | 40 ++++++------------- 5 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/CharacterEncodingFilter.java create mode 100644 zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/ShiroFilter.java diff --git a/zheng-upms/zheng-upms-rpc-service/src/main/java/com/zheng/upms/rpc/service/impl/UpmsApiServiceImpl.java b/zheng-upms/zheng-upms-rpc-service/src/main/java/com/zheng/upms/rpc/service/impl/UpmsApiServiceImpl.java index 672377bd..9648ff07 100644 --- a/zheng-upms/zheng-upms-rpc-service/src/main/java/com/zheng/upms/rpc/service/impl/UpmsApiServiceImpl.java +++ b/zheng-upms/zheng-upms-rpc-service/src/main/java/com/zheng/upms/rpc/service/impl/UpmsApiServiceImpl.java @@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; /** - * 用户service实现 + * UpmsApiService实现 * Created by shuzheng on 2016/01/19. */ @Service diff --git a/zheng-upms/zheng-upms-server/pom.xml b/zheng-upms/zheng-upms-server/pom.xml index f79f306e..406d7e5a 100644 --- a/zheng-upms/zheng-upms-server/pom.xml +++ b/zheng-upms/zheng-upms-server/pom.xml @@ -33,8 +33,8 @@ javax.servlet - servlet-api - 2.5 + javax.servlet-api + 3.1.0 provided diff --git a/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/CharacterEncodingFilter.java b/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/CharacterEncodingFilter.java new file mode 100644 index 00000000..0465747c --- /dev/null +++ b/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/CharacterEncodingFilter.java @@ -0,0 +1,22 @@ +package com.zheng.upms.server; + +import javax.servlet.DispatcherType; +import javax.servlet.annotation.WebFilter; +import javax.servlet.annotation.WebInitParam; + + +/** + * 强制进行转码过滤器 + * Created by shuzheng on 2017/6/24. + */ +@WebFilter( + filterName = "CharacterEncodingFilter", + urlPatterns = "/*", + dispatcherTypes = {DispatcherType.REQUEST, DispatcherType.FORWARD}, + initParams = { + @WebInitParam(name = "encoding", value = "UTF-8") + } +) +public class CharacterEncodingFilter extends org.springframework.web.filter.CharacterEncodingFilter { + +} diff --git a/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/ShiroFilter.java b/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/ShiroFilter.java new file mode 100644 index 00000000..610364db --- /dev/null +++ b/zheng-upms/zheng-upms-server/src/main/java/com/zheng/upms/server/ShiroFilter.java @@ -0,0 +1,20 @@ +package com.zheng.upms.server; + +import javax.servlet.annotation.WebFilter; +import javax.servlet.annotation.WebInitParam; + + +/** + * shiroFilter + * Created by shuzheng on 2017/6/24. + */ +@WebFilter( + filterName = "shiroFilter", + urlPatterns = "/*", + initParams = { + @WebInitParam(name = "targetFilterLifecycle", value = "true") + } +) +public class ShiroFilter extends org.springframework.web.filter.DelegatingFilterProxy { + +} diff --git a/zheng-upms/zheng-upms-server/src/main/webapp/WEB-INF/web.xml b/zheng-upms/zheng-upms-server/src/main/webapp/WEB-INF/web.xml index c36b5ed7..316247f1 100644 --- a/zheng-upms/zheng-upms-server/src/main/webapp/WEB-INF/web.xml +++ b/zheng-upms/zheng-upms-server/src/main/webapp/WEB-INF/web.xml @@ -4,22 +4,6 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> - - - CharacterEncodingFilter - org.springframework.web.filter.CharacterEncodingFilter - - encoding - UTF-8 - - - - CharacterEncodingFilter - /* - REQUEST - FORWARD - - org.springframework.web.context.ContextLoaderListener @@ -53,18 +37,18 @@ - - shiroFilter - org.springframework.web.filter.DelegatingFilterProxy - - targetFilterLifecycle - true - - - - shiroFilter - /* - + + + + + + + + + + + +