当我使用方法响应并且我没有任何关于如何修复它的线索时,我收到上述消息,我有java servlet 3.1这似乎是我能在其他地方找到的唯一答案解决它。
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class login extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServlet response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String username = request.getParameter("username");
String password = request.getParameter("password");
if(Validate.checkUser(username, password))
{
RequestDispatcher rs = request.getRequestDispatcher("Welcome");
rs.forward(request, response);
}
else
{
out.println("Username or Password incorrect");
RequestDispatcher rs = request.getRequestDispatcher("login.html");
rs.include(request, response);
}
}
}
答案 0 :(得分:2)
检查你发布的方法 HttpServlet有doPost方法接受HttpServleRequest和HttpServletResponse参数
protected void doPost(HttpServletRequest request, HttpServlet response) throws ServletException, IOException {
到
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {