為了避免jsp跳jsp,servlet跳jsp,forward方式跳轉,sendRedirect跳轉產生的路徑問題,
對于jsp和使用sendRedirect跳轉的servlet,采用直接使用帶
容器路徑[String request.getContextPath()]的絕對路徑就可以徹底解決,即:
1)<%
String contextPath = request.getContextPath();
String url = contextPath + "/user/login.jsp";
%>
<a href="<%=url%>"> login</a>
2) ....
String contextPath = request.getContextPath();
String targetPath = contextPath + "/user/login.jsp";
RequestDispatcher rd = request.getRequestDispatcher(targetPath);
rd.forward(request, response);
......
對于使用forward跳轉的servlet,則不要加容器路徑,否則就重復出現 容器路徑,