英文:
WAR deployment in tomcar
问题
我在这里需要一些建议。我已经在Tomcat服务器上部署了一个基于Java的应用程序。Tomcat服务器安装在AWS云上。我使用URL格式为hostname:portno/WAR文件名来运行该应用程序,但当我尝试在浏览器中访问该应用程序时,它会抛出404错误。然而,当我在URL之后添加index.html,或者使用任何其他带有.html扩展名的名称,比如hostname:port/warname/abc.html,我的应用程序可以正常运行。请问您为什么不添加index.html就无法运行呢?
英文:
I need some advise over here. I have deployed a java based app on tomcat server. Tomcat server is installed on aws cloud. I am using the URL as hostname:portno/WAR file name to run the app and When i try to hit the app on browser it throws an error 404. However, when i add index.html after the URL or any other name with .html extsn like for ex hostname:port/warname/abc.html my app runs fine. Can you please advise why it is not running without index.html.
答案1
得分: 0
回答您的问题与此线程中的被接受答案有关<br>
https://stackoverflow.com/questions/3976160/how-does-tomcat-find-the-home-page-of-my-web-app
简而言之,在WEB-INF/web.xml下必须定义一个主页,如果未定义任何内容,则TOMCAT_HOME/conf/web.xml文件中定义的内容将被Tomcat服务器视为主页。
所以在您的情况下,我认为您没有在WEB-INF/web.xml中定义特定的主页,这就是为什么Tomcat会搜索默认配置中的index.html页面,但是index.html对于Tomcat来说是不可用的,所以您看到了404错误。当您把index.html文件放在那里后,一切就开始正常工作了。
英文:
Answer to your question has got to do something with the accepted answer in this thread <br>
https://stackoverflow.com/questions/3976160/how-does-tomcat-find-the-home-page-of-my-web-app
Simply put, Under WEB-INF/web.xml a home page has to be defined, if nothing is defined then what ever is defined in TOMCAT_HOME/conf/web.xml file will be considered as home page by tomcat server
so in your case I think you did not define a specific home page in WEB-INF/web.xml, that is why tomcat was searching for index.html page which is as per default configuration but index.html is not available to tomcat, so you were seeing 404 error. As soon as you put index.html file there then everything started to work for you
专注分享java语言的经验与见解,让所有开发者获益!
评论