简体   繁体   English

无法使用tomcat7重新加载服务器

[英]can not reload server with tomcat7

I created a web application using eclipse and Tomcat 7 I had the following code in the html file and the java servlet class in the html file: 我使用eclipse和Tomcat 7创建了一个Web应用程序,在html文件中有以下代码,在html文件中有java servlet类:

<form action="UserAccessServlet" method = "get">

in the servlet class I had 在我的servlet类中

@WebServlet ("/UserAccessServlet")

then I just made some small changes (new println statements) but it shows no effect I changed the server name with the following peice of code 然后我做了一些小改动(新的println语句),但是用下面的代码修改了服务器名称没有效果。

html file: <form action="SQA_Servlet" method = "get"> java class: @WebServlet ("/SQA_Servlet") html文件: <form action="SQA_Servlet" method = "get"> java类: @WebServlet ("/SQA_Servlet")

but it seems that no reload take place and I got the following error: 但似乎没有重新加载发生,并且出现以下错误:

HTTP Status 404 - /SQA_Learning/SQA_Servlet

--------------------------------------------------------------------------------

type Status report

message /SQA_Learning/SQA_Servlet

description The requested resource (/SQA_Learning/SQA_Servlet) is not available.

I tried clean the module, refresh, close the reopen the project with the same result 我尝试清理模块,刷新,关闭后重新打开项目,结果相同

I replaced @WebServlet ("/SQA_Servlet") with @WebServlet(urlPatterns={"/SQA_Servlet"}) 我用@WebServlet(urlPatterns={"/SQA_Servlet"})替换了@WebServlet ("/SQA_Servlet") @WebServlet(urlPatterns={"/SQA_Servlet"})

and still have no effect.. any suggestion. 仍然没有效果..任何建议。

I encounter the same problem, and I deleted web.xml . 我遇到了同样的问题,并删除了web.xml。 after that, I get the right result. 之后,我得到正确的结果。

Another way add metadata-complete="true" like this 这样的另一种方法添加metadata-complete="true"

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"
    metadata-complete="true">

</web-app>

我认为您需要在@WebServlet标记中指定此代码:

@WebServlet(name="UserAccessServlet", urlPatterns="/SQA_Servlet")

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

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