gistfile1.txt package com.fz.filter;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import javax.serv
package com.fz.filter; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @WebFilter("/admin/*") public class AuthFilter implements Filter { @Override public void destroy() { } @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain c) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest)req; HttpServletResponse response = (HttpServletResponse) res; HttpSession s = request.getSession(); String url = request.getRequestURI(); //System.out.println(url); if(!url.endsWith("login.jsp") && s.getAttribute("admin")==null){ if(req.getParameter("type")!=null && req.getParameter("type").equals("login")){ }else{ response.setCharacterEncoding("utf-8"); PrintWriter out = response.getWriter(); out.print(""); out.flush(); out.close(); } //response.sendRedirect("adminlogin.jsp"); } c.doFilter(req, res); } @Override public void init(FilterConfig cfg) throws ServletException { } }