我每次在端点上调用时,我的简单HttpServlet都会被调用两次(我通过使用APM发现): http://cdctst1j:15611/TomSampleServlet/TomSampleServletClient
能帮我看看吗? 这很简单。
WEB-INF \ classes \ TomSampleServletClient.java:
import java.io.IOException;
import java.net.URL;
import java.net.HttpURLConnection;
import java.lang.ClassNotFoundException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public final class TomSampleServletClient extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
xxxx;
xxxx;
}
}
WEB-INF \ web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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">
<servlet>
<servlet-name>TomSampleServletClient</servlet-name>
<servlet-class>TomSampleServletClient</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TomSampleServletClient</servlet-name>
<url-pattern>/TomSampleServletClient</url-pattern>
</servlet-mapping>
</web-app>
非常感谢。