我们在哪里将Servlet放在Tomcat的目录结构中? [英] Where do we put the Servlets in the directory structure of Tomcat?
问题描述
我复制了一个从网上获得的HelloServlet应用程序并将其放在ROOT文件夹中。
我运行了服务器,它不起作用。
有什么问题?我认为它是关于Java类的位置。
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.
推荐答案
本文档可以帮助您
http://tomcat.apache.org/tomcat -7.0-doc / appdev / deployment.html
/ WEB-INF / classes / - 此目录包含任何Java类应用程序所需的文件(和相关资源),包括servlet和非servlet类,它们不会合并到JAR文件中。如果您的类被组织成Java包,则必须在/ WEB-INF / classes /下的目录层次结构中反映出来。例如,名为com.mycompany.mypackage.MyServlet的Java类需要存储在名为/WEB-INF/classes/com/mycompany/mypackage/MyServlet.class的文件中。
/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.
这篇关于我们在哪里将Servlet放在Tomcat的目录结构中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!