gpt4 book ai didi

java - Java 中 HttpServlet 类型错误的方法未定义

转载 作者:行者123 更新时间:2023-12-02 05:54:57 25 4
gpt4 key购买 nike

当我使用响应方法时,我收到上述消息,并且我没有任何关于如何修复它的线索,我有 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);
}
}

}

最佳答案

检查你的发帖方法 HttpServlet有 doPost 方法,它接受 HttpServleRequest 和 HttpServletResponse 参数

protected void doPost(HttpServletRequest request, HttpServlet response) throws ServletException, IOException {

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws     ServletException, IOException {

关于java - Java 中 HttpServlet 类型错误的方法未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23194250/

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