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:
<form action="UserAccessServlet" method = "get">
in the servlet class I had
@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
html file: <form action="SQA_Servlet" method = "get">
java class: @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"})
and still have no effect.. any suggestion.
I encounter the same problem, and I deleted web.xml . after that, I get the right result.
Another way add metadata-complete="true"
like this
<?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")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.