大家好,
我对这个J2EE非常陌生。我必须以"localhost:8080“的形式访问servlet URL
我的web.xml文件如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Ticky taka</servlet-name>
<servlet-class>servlets.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ticky taka</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>问题是,如果我想访问Servlet,就必须给出10.10.10.114:8080/TickyTacka/ URL。而不是上面的URl,我希望将它作为
10.10.10.114:8080有没有可能
我正在使用Apache tomcat 7
请指点
谢谢
发布于 2014-07-18 12:02:34
Tomcat有应用程序上下文路径的概念,外部是应用程序的名称,在您的例子中是TickyTacka,内部是应用程序安装在webapps目录下的路径。
有一个特例ROOT应用程序上下文。在内部,它是目录webapps/ROOT,但它被映射到一个空的应用程序上下文路径。因此,如果您将web应用程序部署到ROOT,则可以在http://10.10.10.114:8080/上访问它。
但它是一种特殊的应用环境,我知道它的用法是不推荐的。正如vbera所说,在正常的应用程序上下文路径中部署应用程序,并在通过apache或nginx重写URL之后隐藏这些路径更为常见。
https://stackoverflow.com/questions/24823483
复制相似问题