- 在我们的项目中,什么时候“/”被认为是服务器根目录:http://localhost/
- jsp里的都是:
超链接:<a href="/a.jsp">超链接</a>
form表单:<form action="/a.jsp">
- Servlet里:
重定向:response.sendRedirect("/a.jsp")
为了不出错,上述三种情况下,一定要写绝对路径:在前面加request.getContextPath()
- 在我们的项目中,什么时候“/”被认为是web应用自己的根目录:http://localhost/project/
- Servlet里的转发:
request.getRequestDispatcher("/a.jsp")
- web.xml里的servlet-mapping中的url映射:
<servlet-mapping>
<servlet-name>UserController</servlet-name>
<servlet-pattern>/a.jsp</servlet-pattern>
</servlet-mapping>
- 自定义标签中的/也是