HttpSession session = request.getSession();
这里的
request 必须是
javax.servlet.http.HttpServletRequest;
session必须是:
javax.servlet.http.HttpSession;
如果说你现在只有 javax.servlet.ServletRequest对象的话
你要转换一下
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpSession session=request.getSession();
} |