public void doFilter(ServletRequest servletrequest, ServletResponse servletresponse,
FilterChain filterchain) throws IOException, ServletException {
HttpServletRequest request=(HttpServletRequest)servletrequest;
//接受用户请求的地址
String url = request.getServletPath();
//判断用户请求的地址,并执行相应程序
if(url.equals("/register.action")){
request.getRequestDispatcher("register.jsp").forward(servletrequest, servletresponse);
return ;
}
else if(url.equals("/saveUser.action")){
String name = request.getParameter("user");
String password = request.getParameter("password");
String password1 = request.getParameter("password1");
if(password.equals(password1)){
User us = new User();
us.setUsername(name);
us.setPassword(password);
//执行DAO持久化操作
request.getRequestDispatcher("end.jsp").forward(servletrequest, servletresponse);
return ;
}
else{
request.getRequestDispatcher("register.jsp").forward(servletrequest, servletresponse);
return ;
}
}
//跳转到相应界面
filterchain.doFilter(servletrequest, servletresponse);
}
大咪
一瞬儿光
行恒
Tobey_滔
相关分类