forked from vonzhou/SpringInAction3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
冯周
committed
Jul 23, 2016
1 parent
921eac8
commit 9a6fee4
Showing
6 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
spring-interceptor/src/main/java/com/vonzhou/learning/filter/SimpleServletFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.vonzhou.learning.filter; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
import javax.servlet.*; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Created by vonzhou on 16/7/23. | ||
*/ | ||
public class SimpleServletFilter implements Filter{ | ||
private static Logger logger = Logger.getLogger(SimpleServletFilter.class); | ||
|
||
public void init(FilterConfig filterConfig) throws ServletException { | ||
logger.info("SimpleServletFilter init...."); | ||
} | ||
|
||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { | ||
String id = request.getParameter("id"); | ||
if(id != null && !id.isEmpty() && !id.equals("123")){ | ||
chain.doFilter(request,response); | ||
} | ||
|
||
// Reply directly here | ||
HttpServletResponse httpResponse = (HttpServletResponse)response; | ||
httpResponse.getWriter().println("+++ From Filter, Another Page...enjoy"); | ||
} | ||
|
||
public void destroy() { | ||
logger.info("SimpleServletFilter destroy...."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello TXT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters