authenticationfilter.java

来自「webwork in action 下载。」· Java 代码 · 共 42 行

JAVA
42
字号
package org.hibernate.auction.web.filters;import org.hibernate.auction.model.User;import javax.servlet.*;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import java.io.IOException;public class AuthenticationFilter implements Filter {    public static final String USER = "user";           public void destroy() {    }    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {            	HttpSession httpSession = ((HttpServletRequest) request).getSession(true);    	User u = null;     			    	u = (User)httpSession.getAttribute(USER);    			    	if(u != null)   	    	    chain.doFilter(request, response);           	    }           /**     * Does nothing.     */    public void init(FilterConfig filterConfig) throws ServletException {    }   }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?