简体   繁体   中英

Library Java Project to Dynamic Web Project

I am attempting to make this java application web accessible: http://ge.tt/4jnFeFy/v/0

I have imported it successfully into eclipse and followed this guide to convert it to a web project:

http://www.mkyong.com/java/how-to-convert-java-project-to-web-project-in-eclipse/

I have then exported the project as a war file which you can see here if interested: http://ge.tt/48bpeFy/v/0

I put the war file into my webapps directory and it self-extracted to a new folder where I should be able to access it. However when I go to localhost/library I get a 404 error.

HTTP Status 404 - /library/

type Status report

message /library/

description The requested resource (/library/) is not available.
Apache Tomcat/7.0.26

I downloaded the sample war from here: http://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/ and put that in my webapps folder and had no problem accessing it from localhost/sample.

Why is the java application I converted to a web project not working?

There are lot of reason's why your war won't work as expected.

  • The link you followed is just to convert a java app project to web app project in Eclipse. And it doesn't guarantee that it'll work in an Application Server. ie, what you've done is just made the Eclipse to recognize that project as Dynamic Web Application.

  • Do you have any servlets or jsp or html pages inside that war? Without it, Web App may not work.

  • Did you check the WEB-INF/web.xml which might not the properly configured.

  • Or your project might not have any welcome page. So, you got 404.

If possible, upload your deployed war to tell the exact reason.

我已经下载了Library项目。它应该是桌面应用程序,而不是Web应用程序。如果要将其转换为Web应用程序,则应自己编写servlet或jsp。在编写完servlet或jsp或其他组件后,将其转换为Web项目?如果没有,则出现404错误是正常现象。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM