JSP和Servlet之间跳转总结:
Request.getContextPath() 即代表 /项目名。 如/news01
一、从JSP页面跳到其他页面或Servlet
从JSP页面跳到其他页面使用全路径( /项目名/文件的路径 )。如项目名为news01,页面目录如下
1)比如从index.jsp页面跳到main文件夹下的list.jsp页面:
链接路径为:/news01/main/list.jsp
2) 比如从index.jsp页面跳到自己页面:
链接路径为: /news01/index.jsp
3) 比如从list.jsp页面跳到index.jsp页面:
链接路径为: /news01/index.jsp
4)比如从list.jsp页面跳到insert.jsp页面
链接路径为: /news/main/insert.jsp
5)Servlet的url路径为:/servlet/TestServlet.
从任何JSP页面跳转到该servlet的链接路径为:/news01/servlet/TestServlet
6) Servlet的url路径为:/TestServlet.
从任何JSP页面跳转到该servlet的链接路径为:/news01/TestServlet
7)Form表单的action路径示例:
相关推荐: