@WebServlet(
name = "HomeServlet",
description = "Homepage Servlet Configuration",
urlPatterns = {"/HomeServlet", "/RegisterServlet"}
)
public class HomeServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
RequestDispatcher dispatcher= request.getRequestDispatcher( "/WEB-INF/pages/index.jsp" );
dispatcher.forward( request, response );
RequestDispatcher dispatcher= request.getRequestDispatcher( "/WEB-INF/pages/register.jsp" );
dispatcher.forward( request, response );
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}
到目前为止,我只配置了我的HomeServlet Java Servlet,当我的HTML前端表单被提交时,它重定向到Index.jsp。
修改 我的问题是如何将特定的URL模式重定向到我的不同jsp页面。