英文:
Springboot running on external Tomcat server gives error 404 on everything but index.html
问题
我基本上确定问题出在我正在运行的外部远程 Tomcat 服务器上:应用程序的任何路径作为索引(10.0.0.222:8080/demo-0.0.1-SNAPSHOT)是正常的,但在此基础上(10.0.0.222:8080/demo-0.0.1-SNAPSHOT/home)会导致404错误。在使用嵌入式 Tomcat 服务器运行时,此路径正常工作;在本地主机上运行外部 Tomcat 服务器时也是如此,因此我相当确定问题出在我的远程 Tomcat 服务器上。我不知道是什么原因导致了这个问题,所以非常感谢任何帮助,如果有任何更多的信息/文件可以提供,请告诉我。
<strike>我在我的 Spring Boot 项目中遇到了这个问题,当使用嵌入式 Tomcat 服务器运行应用程序时,一切正常,但是当我将项目编译打包为 WAR 文件以便部署到我的外部 Tomcat 服务器时,我无法向其发送请求,而且主方法中的代码也不会运行。
https://github.com/louisspaghetti/demo
一些注意事项:
将其部署到外部 Tomcat 或在 Tomcat 上启动时没有错误。
当使用嵌入式 Tomcat 运行时,我可以发送请求到 localhost:8080/home,但是对 10.0.0.222:8080/demo-0.0.1-SNAPSHOT/home(访问外部 Tomcat)的请求会导致404错误。
我在 Tomcat 服务器上还有另一个项目,使用原始的 Java Servlets 制作,它能正常运行,因此我认为问题不在于我的 Tomcat 配置,但我猜也有可能……
编辑:我添加了另一个映射以返回 index.html,这样做有效,但是“/home”(或 10.0.0.222:8080/demo-0.0.1-SNAPSHOT/home)仍然无法正常工作。
编辑 2:在最近在本地主机上创建的 Tomcat 服务器上运行时,该应用程序在 /home 路径下工作正常。我之前在远程 Tomcat 服务器上工作的另一个应用程序现在只能像 index.html 一样工作,这使我相信这一定是服务器出了问题?有人知道我需要做什么来解决这个问题吗? </strike>
已解决:使用 Tomcat 9 而不是 10。
英文:
I've basically pinned down the issue to be something wrong with an external remote tomcat server I have running: where any path of an application that would be the index (10.0.0.222:8080/demo-0.0.1-SNAPSHOT) works but past that (10.0.0.222:8080/demo-0.0.1-SNAPSHOT/home) results in an error 404. This path works when running with an embedded tomcat server and when running an external tomcat server on my localhost machine so I'm pretty sure that the issue is something wrong with my remote tomcat server. I have no idea what could be causing this so I appreciate any help and if there are any more information/files I can provide, please let me know.
<strike>I have this problem with my spring boot project where the application runs fine when using the embedded tomcat server, but when I compile and package the project as a war in order to deploy it on my external tomcat server, I can't send requests to it and the code in the main method doesn't run
https://github.com/louisspaghetti/demo
Some notes:
There are no errors when I deploy it to external tomcat/when I start it on tomcat.
I'm able to send requests to localhost:8080/home when running with embedded tomcat but requests to 10.0.0.222:8080/demo-0.0.1-SNAPSHOT/home (accessing external tomcat) results in error 404.
I have another project on the tomcat server that I made with raw java servlets and it runs fine, so I don't think it's a problem with my tomcat config but I guess it could be...
EDIT: I added another mapping for "/" to return index.html and that worked but "/home" (or 10.0.0.222:8080/demo-0.0.1-SNAPSHOT/home) still doesn't work
EDIT 2: The application works with the /home path when running on a tomcat server I recently created on my local host machine. The other application I had working before on my remote tomcat server now only works with index.html as well making me believe this must be an issue with the server? Does anyone know of what I have to do to fix this? </strike>
FIXED: Use Tomcat 9 instead of 10
答案1
得分: 0
我找到了解决方法:使用 Tomcat 9 而不是 10。
英文:
I found the fix: use tomcat 9 instead of 10
专注分享java语言的经验与见解,让所有开发者获益!
评论