1

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.

4

2 回答 2

0

我认为您需要在@WebServlet标签中指定此内容:

@WebServlet(name="UserAccessServlet", urlPatterns="/SQA_Servlet")
于 2011-04-28T11:05:24.833 回答
0

我遇到了同样的问题,我删除了 web.xml 。之后,我得到了正确的结果。

另一种添加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>
于 2013-04-26T03:47:23.817 回答