[英]where to copy servlet files in apache tomcat server to work fine with web?
Can anyone guide me how to get Servlets working in Apache Tomcat server? 谁能指导我如何使Servlet在Apache Tomcat服务器中工作? I can run the Servlets from Netbeans without problems, but I don't know where to put the class files in Tomcat. 我可以毫无问题地从Netbeans运行Servlet,但是我不知道将类文件放在Tomcat中的位置。
In tomcat: 在tomcat中:
TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/classes
类文件必须位于TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/classes
TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/lib
jar文件必须位于TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/lib
(and if course you'll need web.xml
in WEB-INF
) (如果您当然需要WEB-INF
web.xml
)
They go in Tomcat/webapps
folder. 它们进入Tomcat/webapps
文件夹。 There are several ways to deploy a JSP/Servlet webapplication on Tomcat. 有几种方法可以在Tomcat上部署JSP / Servlet Web应用程序。 They are all described in Tomcat Web Application Deployment HOW-TO . 所有这些都在Tomcat Web应用程序部署HOW-TO中进行了描述。
If you already have developed the webapplication in Netbeans, then Netbeans should already have build a WAR file of it in the /dist
folder. 如果您已经在Netbeans中开发了Web应用程序,则Netbeans应该已经在/dist
文件夹中为其构建了WAR文件。 You just need to drop the WAR file in Tomcat/webapps
folder and Tomcat will automatically deploy it during startup (or even while running, this is called hotdeploy ). 您只需要将WAR文件拖放到Tomcat/webapps
文件夹中,Tomcat就会在启动过程中(甚至在运行时自动部署它,这称为hotdeploy )。
If you want to develop without an IDE and/or don't want to create a WAR, then you just need to put a folder representing the context name in Tomcat/webapps
, eg Tomcat/webapps/contextname
. 如果要在没有IDE的情况下进行开发和/或不想创建WAR,则只需在Tomcat/webapps
放置一个表示上下文名称的文件夹,例如Tomcat/webapps/contextname
。 It will become the public web content. 它将成为公共Web内容。 You can drop all JSP files and other static files in there. 您可以在其中放置所有JSP文件和其他静态文件。 Then, for classes you need to create a Tomcat/webapps/contextname/WEB-INF/classes
folder. 然后,对于类,您需要创建Tomcat/webapps/contextname/WEB-INF/classes
文件夹。 There should go the package structure. 应该有包装结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.