Where do we put the Servlets in the directory structure of Tomcat?

I copied a HelloServlet application i got from the web and put it in the ROOT folder. I ran the server and it doesn't work. What is wrong? I think its about the location of the Java classes.


this documentation should help you

http://tomcat.apache.org/tomcat-7.0-doc/appdev/deployment.html

/WEB-INF/classes/ - This directory contains any Java class files (and associated resources) required for your application, including both servlet and non-servlet classes, that are not combined into JAR files. If your classes are organized into Java packages, you must reflect this in the directory hierarchy under /WEB-INF/classes/. For example, a Java class named com.mycompany.mypackage.MyServlet would need to be stored in a file named /WEB-INF/classes/com/mycompany/mypackage/MyServlet.class.


you have to put the web application in webapp folder in tomcat.

Also the url should be

http://localhost:8080/folder_name


You should put them in WEB-INF/classes . "This directory is for servlets, utility classes, and the Java compiler output directory"

链接地址: http://www.djcxy.com/p/3992.html

上一篇: 隐式转换为指向数据成员与非指针的指针

下一篇: 我们将Servlets放在Tomcat的目录结构中?