Change root context for a servlet in an IntelliJ I

2019-01-26 12:27发布

问题:

I have created two servlets that run when I use their url-pattern that is defined in my web.xml file.

For example, to run the first one I type the following in my browser:

http://localhost:8080/XmlServletPath

I want to find a way to run these servlets from a different root context, for example:

http://localhost:8080/SimpleServletProject/XmlServletPath

When I try the above URL now I am getting the following error:

HTTP Status 404 - /SimpleServletProject/XmlServletPath

type Status report
message /SimpleServletProject/XmlServletPath
description The requested resource is not available.

PS: I am using Tomcat 7.0.35.

回答1:

Application context can be specified in the Deployment tab of the Tomcat Run/Debug configuration: