首页 > 代码库 > Filter中获取session的属性

Filter中获取session的属性

public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException,ServletException{
System.out.println("filter1-in");

HttpServletRequest httpRequest = (HttpServletRequest)request;

HttpSession session = httpRequest.getSession();
String uid = (String)session.getAttribute("uid");

System.out.println("uid ==" + uid);             //输出获得的session中属性的值
if(uid == null){
return;
}
chain.doFilter(request, response);
System.out.println("filter1-out");
}

Filter中获取session的属性