gpt4 book ai didi

tomcat - 错误 404,Tomcat 找不到 servlet

转载 作者:行者123 更新时间:2023-11-28 23:05:00 28 4
gpt4 key购买 nike

<分区>

我想在我的 Maven 项目中编写一个简单的 servlet,但我收到此错误请求的 url (/src/main/java/web.servlets.FunctionalTestServlet) 在此服务器上找不到。

这是我的代码:

Servlet:位于src/main/java打包 web.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class FunctionalTestServlet extends HttpServlet
{

public void doGet(HttpServletRequest request,HttpServletResponse response)throws
ServletException, IOException {

PrintWriter out = response.getWriter();
out.println( "SimpleServlet Executed" );
out.flush();
out.close();
}


public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String fileName = request.getParameter("testfile");
out.println("<b><font color='blue'>The File name is
:</font></b>"
+ "<b>"+ fileName +"</b>" + "<br>");
}
}

jsp页面:src/main/webapp下

 <html:file properties="tonFichier" name="tonForm"/>


<form action="/src/main/java/web.servlets.FunctionalTestServlet"
enctype="multipart/form-data" method="post">
<p>
Type some text (if you like):<br>
<input type="text" name="textline" size="30">
</p>
<p>
Please specify a Test , or a set of tests:<br>
<input type="file" name="testfile" size="40" >
</p>
<div>
<input type="submit" value="Execute Test">

</div>
</form>
</body>
</html>

这是我的 web.xml:在/WebTestAutomatisation/src/main/webapp/WEB-INF/web.xml 下

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
<display-name>Archetype Created Web Application</display-name>

<servlet>
<servlet-name>FunctionalTestServlet</servlet-name>
<servlet-class>web.servlets.FunctionalTestServlet.java</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FunctionalTestServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

</web-app>

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com