【发布时间】:2013-02-16 10:00:10
【问题描述】:
我创建了一个eclipse动态web项目,home.jsp在WEB-INF文件夹中
我使用的服务器是Tomcat 7.0.35
项目的名称是 Pilot_1,我有一个 servlet,它在 URL 模式为 /home 时触发
@WebServlet(description = "Initalizes the table", urlPatterns = { "/home" })
我想指定 URL,这样每次我按 Project > Run > Run on Server 时,URL 就是 localhost:8080/Pilot_1/home(同时触发 servlet 和 jsp 页面)。
我尝试将 Context Root 更改为仅“Pilot_1”,这会提供 URL“localhost:8080/Pilot_1”并且不会触发 servlet
我尝试将 Context Root 更改为“Pilot_1/home”,这提供了 URL“localhost:8080/Pilot/1/home/”,额外的“/”确保 servlet 不会触发
我尝试将 Context Root 更改为“home”,这会给出 URL“localhost:8080/home/”,而且额外的 '/' 确保 servlet 不会触发
我一直在使用 URL,似乎唯一一次触发 servlet 是当 URL 为“localhost:8080/Pilot_1/home”时
有什么解决办法吗?
这是我的 web.xml
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>home.jsp</welcome-file>
【问题讨论】: