0

我在 Windows 10 上安装了 tomcat 9.0.40 并从 Eclipse 部署到它。Tomcat 总是以 404 响应,即使我在其他帖子中发现了我介绍的所有修改。

这是我当前的设置:

Eclipse server config,指向Eclipse中的配置,使用tomcat安装路径,部署到webapps目录下:

Eclipse 服务器配置

Eclipse 服务器配置中的 server.xml 使用端口 8087,即 webapps 目录并显示部署的上下文:

<Connector connectionTimeout="20000" port="8087" protocol="HTTP/1.1" redirectPort="8443"/>
...
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
...
<Context docBase="projects-topics-ws" path="/projects-topics-ws" reloadable="true" source="org.eclipse.jst.jee.server:projects-topics-ws"/></Host>

我的 Eclipse Server 视图显示了部署的 webapp:

Eclipse 服务器视图中的 Webapp

并且 webapp 安装在 webapps 目录中:

已部署的 webapp

在 Eclipse Project Facets 中,我检查了“Dynamic Web Module 4.0”和“JAX-RS Webservice 2.1”,但这似乎也无济于事。

我可以访问 tomcat manager 应用程序,http://localhost:8087/manager/html它显示我的应用程序已部署并正在运行。

尽管如此,如果我在应用程序基路径访问应用程序,tomcat 会响应 404 http://localhost:8087/projects-topics-ws/,它应该响应 XML 内容。

有什么我想念的想法吗?

4

1 回答 1

1
  1. 你重启Tomcat了吗?conf/server.xml重启后不会重新加载。

  2. cite: 'The server.xml from the Eclipse Server' : 检查文件是否真的被评估好(例如,如果你不确定,更改端口并重新启动服务器)。

  3. 您的 appBase 是相对于$CATALINA_BASE目录的,因此您可能需要仔细检查。看起来应该没问题,因为经理 webapp 似乎在同一个目录下工作正常,但我知道有些人并行安装了多个服务器并因此而受到误导。

  4. 您只是检查了基本 URL 还是来自 的特定(最佳静态)资源http://localhost:8087/projects-topics-ws/?例如http://localhost:8087/projects-topics-ws/html/index.html

  5. 您是否定义了欢迎页面?如果调用基本 url,Tomcat 将查找这样的文件(如果已定义):

<welcome-file-list>
<welcome-file>
   index.html
</welcome-file>
</welcome-file-list>
  1. 您是在浏览器中使用 URL 还是在 Tomcat 管理控制台中单击路径,它会显示您部署的应用程序?浏览器中的路径是否相同?
于 2020-12-09T09:51:20.657 回答