jsp没有登陆,怎么才能不让用户进入其它页面 写一个过滤器-LoginFilterimport javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;import electroniccommerceweb.entity.Member;import electroniccommerceweb.entity.Cart;public class LoginFilter extends HttpServlet implements Filter {private FilterConfig filterConfig;Handle the passed-in FilterConfigpublic void init(FilterConfig filterConfig)throws ServletException {this.filterConfig=filterConfig;}Process the request/response pairpublic void doFilter(ServletRequest request,ServletResponse response,FilterChain filterChain){try {HttpServletRequest req=(HttpServletRequest)request;HttpServletResponse res=(HttpServletResponse)response;HttpSession session=req.getSession();LoginInfo login=(LoginInfo)session.getAttribute(\"login\");此session是你在登录是放入的用户实体if(login=null){res.sendRedirect(\"login.jsp\");}else{filterChain.doFilter(request,response);}} catch(ServletException sx){filterConfig.getServletContext().log(sx.getMessage());} catch。
JSP显示 页面一点登陆就报错,实在是找不到原因啊 404错误,没有找到/aa/loginServlet 这个servlet检查你的xml配置文件是否正确。检查你的路径是否有这个servlet把路径写全试试。jsp页面可以在前面加上绝对路径${pageContext.request.contextPath}/aa/loginServlet 这样试试
jsp没有登陆,怎么才能不让用户进入其它页面拜托各位了 3Q 写一个过滤器-LoginFilter import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;import electroniccommerceweb.entity.Member;import electroniccommerceweb.entity.Cart;public class LoginFilter extends HttpServlet implements Filter { private FilterConfig filterConfig;Handle the passed-in FilterConfig public void init(FilterConfig filterConfig)throws ServletException { this.filterConfig=filterConfig;}/Process the request/response pair public void doFilter(ServletRequest request,ServletResponse response,FilterChain filterChain){ try { HttpServletRequest req=(HttpServletRequest)request;HttpServletResponse res=(HttpServletResponse)response;HttpSession session=req.getSession();LoginInfo login=(LoginInfo)session.getAttribute(\"login\");此session是你e69da5e6ba90e799bee5baa6e997aee7ad9431333335313862在登录是放入的用户实体 if(login=null){ res.sendRedirect(\"login.jsp\");} else { filterChain.doFilter(request,response);} } catch(ServletException sx){ filterConfig。.