package com.neuedu.filter;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
/**
* Created by ttc on 16-12-5.
*/
@WebFilter(filterName = "MyFristFilter",urlPatterns = "/show_all_users.action")
public class MyFristFilter implements Filter
{
public void destroy()
{
}
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException
{
HttpServletRequest httpreq = (HttpServletRequest)req;
HttpServletResponse httpres = (HttpServletResponse)resp;
HttpSession hp = httpreq.getSession();
Object o = hp.getAttribute("username");
if(o == null)
{
httpres.sendRedirect("login.jsp");
return;
}
chain.doFilter(req, resp);
}
public void init(FilterConfig config) throws ServletException
{
}
}
jsp过滤器MyFristFilter
最新推荐文章于 2021-09-02 22:45:12 发布