作者:陈晏亚363951 | 来源:互联网 | 2023-05-19 12:05
IhaveaproblemwithmyServletimplementation.ImusingApacheTomcatastheServletengineandE
I have a problem with my Servlet implementation. I'm using Apache Tomcat as the Servlet engine and Eclipse as the IDE. First I created a search.html as follow:
我的Servlet实现有问题。我使用Apache Tomcat作为Servlet引擎,使用Eclipse作为IDE。首先我创建了一个search.html如下:
Name :
Then I created a servlet, called Servlet1:
然后我创建了一个名为Servlet1的servlet:
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/Servlet1")
public class Servlet1 extends HttpServlet
{
private static final long serialVersiOnUID= 1L;
public Servlet1()
{
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String s= request.getParameter("name");
response.getWriter().write(s);
}
}
And finally the web.xml, located in WebContent\WEB-INF:
最后是位于WebContent \ WEB-INF中的web.xml:
Servlet
servlet1
Servlet1
servlet1
/myServlet
When I enter data inside the input box of search.html and press "OK" I get the following error:
当我在search.html的输入框中输入数据并按“确定”时,我收到以下错误:
HTTP Status 404 - /Servlet1.0/es1
type Status report
message /Servlet1.0/es1
description The requested resource is not available.
I think there are some mistakes with web.xml. In fact, if I change the url-pattern into es1, I don't get an error.
我认为web.xml存在一些错误。事实上,如果我将url-pattern更改为es1,我不会收到错误。
1 个解决方案