首先,请怜悯这个noobie问题。我目前正在开发一个Web应用程序项目,偶然发现了我无法解决的基本问题。
基本上,我有以下内容:
我确实在浏览器中看到了从servlet2返回的内容,但是当我查看IE Developer Tools(F12)时,我发现对servlet2的GET请求永远不会完成(STATUS PENDING)。必须有一些我非常缺乏的基本内容......
在下面的屏幕截图中,“Ausstehend”会转换为“待定”。
IE屏幕截图:
的index.html:
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="servlet1" method="post">
<input type="text" name="test" placeholder="some data">
<button type="submit"><b>send</b></button>
</form>
</body>
</html>
servlet1:
public class servlet1 extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.sendRedirect("servlet2");
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
}
servlet2:
public class servlet2 extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet servlet2</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>HELLO</h1>");
out.println("</body>");
out.println("</html>");
out.close();
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
}