在IntelliJ IDEA项目中更改servlet的根上下文

ski*_*box 8 tomcat servlets intellij-idea

我创建了两个servlet,当我使用我的web.xml文件中定义的url-pattern时运行.

例如,要运行第一个,我在浏览器中键入以下内容:

http://localhost:8080/XmlServletPath
Run Code Online (Sandbox Code Playgroud)

我想找到一种从不同的根上下文运行这些servlet的方法,例如:

http://localhost:8080/SimpleServletProject/XmlServletPath
Run Code Online (Sandbox Code Playgroud)

当我尝试上面的URL时,我收到以下错误:

HTTP Status 404 - /SimpleServletProject/XmlServletPath

type Status report
message /SimpleServletProject/XmlServletPath
description The requested resource is not available.
Run Code Online (Sandbox Code Playgroud)

PS:我使用的是Tomcat 7.0.35.

Cra*_*der 28

可以在Tomcat运行/调试配置的" 部署"选项卡中指定应用程序上下文:

上下文

  • 您正在`/ SimpleServerProject`下部署,但在浏览器中打开的URL是`http:// localhost:8080/SimpleServletProject`.你能看到URL中的**Servlet**和**Server**之间的区别吗?此外,[此映射](http://img685.imageshack.us/img685/7003/20130320030249.png)应设置为`/`. (2认同)