📄 authenticationfilter.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -