简体   繁体   English

JSP的web.xml配置

[英]web.xml configuration for JSP

在此处输入图片说明

This is the structure of the JSP app on eclipse.Once I run it on eclipse using tomcat server(localhost:8090/index4.html) it works.On the index page i have to add details,this details are uploaded via the servlet as you can see above Java Resources->src->FileUPloadDBServlet (Also I am not sure if it uses this or it uses WEB-INF->src->FileUploadServlet below.) In my index4.html the action is action=uploadServlet (no address given for it).This everything works on using eclipse. 这是eclipse上的JSP应用程序的结构。一旦我使用tomcat服务器(localhost:8090 / index4.html)在eclipse上运行它,它就会起作用。在索引页面上,我必须添加详细信息,这些详细信息通过servlet通过servlet上传。您可以在上面看到Java Resources->src->FileUPloadDBServlet (而且我不确定下面是否使用它,或者下面使用WEB-INF->src->FileUploadServlet 。)在我的index4.html ,动作是action=uploadServlet (否地址))。使用eclipse可以正常工作。 But once I put the QMS folder(not WAR) from eclipse worskspace to tomcat ROOT,the index4.html works but the following action,ie uploadServlet doesnt work(here I use the address localhost:8090/WebContent/index4.html)I dont have a web.xml. 但是,一旦我将QMS文件夹(非WAR)从Eclipse Worskspace放置到tomcat ROOT,index4.html即可工作,但以下操作即ieupServlet不起作用(这里我使用的地址为localhost:8090 / WebContent / index4.html)有一个web.xml。 Is that creating a problem? 这是一个问题吗? Please provide me help. 请给我帮助。

You need to put your project folder or .war file in the 您需要将项目文件夹或.war文件放入

webapps folder of Tomcat directly not in ROOT folder under webapps. Tomcat的webapps文件夹直接不在webapps下的ROOT文件夹中。

Try to follow directory structure as follows 尝试遵循以下目录结构

Photo Courtesy http://www.studytonight.com/servlet/steps-to-create-servlet-using-tomcat-server.php (Here you can also find more details on Servlet and JSP, as well as project structure) 照片由 http://www.studytonight.com/servlet/steps-to-create-servlet-using-tomcat-server.php 提供 (在这里您还可以找到有关Servlet和JSP以及项目结构的更多详细信息)

Where you have your web.xml put into the WEB-INF folder under your application folder. 将web.xml放在应用程序文件夹下的WEB-INF文件夹中的位置。 For java files you don't need the source files, the classes folder will have all the source folder (src) files compiled and ready to execute. 对于Java文件,您不需要源文件,classes文件夹将具有所有已编译并准备执行的源文件夹(src)文件。

The lib will contain all the .jar files you need for your application to run. 该库将包含运行应用程序所需的所有.jar文件。

Make sure you put web.xml file at proper place, because without it, application will not be able to run. 确保将web.xml文件放在正确的位置,因为如果没有该文件,应用程序将无法运行。 Because as they say web.xml is Heart of the application. 因为正如他们所说,web.xml是应用程序的心脏。

Let me explain you the problem. 让我向您解释问题。

When we configure a dynamic java project to run on eclipse the server takes the just the stuff from webcontent folder and deploy it the wbcontent folder contains web.xml file which defines the url descriptor for servlet. 当我们将动态Java项目配置为在eclipse上运行时,服务器仅从webcontent文件夹中获取内容并进行部署,而wbcontent文件夹包含web.xml文件,该文件定义了servlet的url描述符。

now when you copy the whole folder the server can not find the web.xml file which is a descriptor where it expects the file to be. 现在,当您复制整个文件夹时,服务器找不到web.xml文件,该文件是它期望文件所在的描述符。

hope its clear comment for clarification 希望它的明确评论可以澄清

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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