Servlets 此URL不支持HTTP方法POST
有人能告诉我为什么我会犯这个错误吗?我在网上做了无休止的搜索,尝试了各种各样的建议,但似乎什么都不起作用。 错误:-此URL不支持HTTP方法POSTServlets 此URL不支持HTTP方法POST,servlets,Servlets,有人能告诉我为什么我会犯这个错误吗?我在网上做了无休止的搜索,尝试了各种各样的建议,但似乎什么都不起作用。 错误:-此URL不支持HTTP方法POST @WebServlet("/LoginProccess") public class LoginProccess extends HttpServlet { private static final long serialVersionUID = 1L; @SuppressWarnings("static-access") public voi
@WebServlet("/LoginProccess")
public class LoginProccess extends HttpServlet {
private static final long serialVersionUID = 1L;
@SuppressWarnings("static-access")
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
DbConnection dbConn = null;
Connection conn = null;
CallableStatement proc = null;
response.setContentType("text/html");
PrintWriter out = response.getWriter();
// get the variables entered in the form
String clientID = request.getParameter("cid");
String loginID = request.getParameter("lid");
String password = request.getParameter("pwd");
String instName = request.getParameter("iName");
try{
dbConn = new DbConnection();
conn = dbConn.connection();
proc = conn.prepareCall("{call pa_internal_admin.fu_login(?,?,?,?)}");
proc.setString(1, clientID);
proc.setString(2, loginID);
proc.setString(3, password);
proc.setString(4, instName);
proc.execute();
response.sendRedirect("adminHome.jsp");
proc.close();
} catch (SQLException e) {
out.println("SQLException caught: " + e.getMessage());
} catch (Exception e) {
out.println(e);
} finally {
// Always close the database connection.
try {
if (conn != null)
conn.close();
} catch (SQLException ignored) {
out.println(ignored);
}
}
}
}
不要更改可见性修改器
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
考虑改为
protected void doPost( HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
您在post方法中犯了一些错误,比如您是type
public
。但是,您必须更改受保护的。首先,在发布问题之前,您必须预览代码
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
DbConnection dbConn = null;
公共和受保护之间的区别:
Modifier | Class | Package | Subclass | World
————————————+———————+—————————+——————————+———————
public | ✔ | ✔ | ✔ | ✔
————————————+———————+—————————+——————————+———————
protected | ✔ | ✔ | ✔ | ✘
谢谢你的回复,这是一个漫长的夜晚,一个非常沮丧的夜晚,我在尝试各种愚蠢的事情。我已经将修饰符改回“protected”,它没有任何区别。任何建议请让我知道你在使用什么url可能你在点击另一个url经过所有的挣扎之后,我删除了这个该死的servlet,并创建了一个具有不同名称的新servlet,并且它工作正常。不,不幸的是,它没有工作,我之前已经将它作为保护,但出于沮丧,我尝试了各种愚蠢的事情。我把它换回了受保护的,但仍然没有乐趣。