具有不同Request Dispatch的JSP多个WebServlet URL模式

时间:2016-06-21 15:52:17

标签: jsp servlets model-view-controller

@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页面。

0 个答案:

没有答案