【问题标题】:removing project name from j2ee web application URL从 j2ee Web 应用程序 URL 中删除项目名称
【发布时间】:2013-08-09 06:44:11
【问题描述】:

我在 eclipse 中有一个 web 动态项目,在 webapps 文件夹中有 index.html,我可以通过以下方式访问它:

http://localhost:8080/javaTest

我想通过以下方式访问我的应用程序:

http://localhost:8080

我尝试通过右键单击项目->属性->Web 项目设置将上下文根更改为“/”,但在http://localhost:8080/ 上找不到请求的资源,并且应用程序仍在http://localhost:8080/javaTest 上运行。

这是我的 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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>javaTest</display-name>
  <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>
</web-app>

编辑:服务器 - tomcat 7.0.34

【问题讨论】:

  • 您使用的是哪个 J2EE 服务器?

标签: url jakarta-ee web


【解决方案1】:
【解决方案2】:

我参考下面的链接解决了这个问题。

How to change context root of a dynamic web project in Eclipse?

务必遵守所有步骤

【讨论】:

  • 请简要描述链接的内容,以防它被破坏
【解决方案3】:

如果您想从您的 URL 中删除应用程序名称或项目名称,只需更改 tomcat 服务器文件 conf/server.xml 文件。

appBase="webapps"

删除“webapps”,只使用“/”

appBase="/"

现在你检查http://localhost:8080

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-26
    • 2016-07-24
    • 2013-09-16
    • 1970-01-01
    • 1970-01-01
    • 2012-12-24
    • 2018-04-11
    • 1970-01-01
    相关资源
    最近更新 更多