[英]HTTP Status 405 - HTTP method POST is not supported by this URL
I try to send some data but it seems like the Controller could not be clear found or could not handle the request. 我尝试发送一些数据,但似乎控制器无法清除或无法处理请求。
test.jsp test.jsp的
<%@ page errorPage="exception.jsp"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page session="true" import="java.io.*,java.util.*"%>
<%@ page import="eng.ku.sku.exceed_vote.knt.*"%>
<form name="AddForm" action="addtext" method="POST">
<input type="hidden" name="todo" value="add">
Add text:<input type="text" name="text" />
<input type="submit" value="Add">
</form>
web.xml web.xml中
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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_2_5.xsd" version="2.5">
<servlet>
<servlet-name>exceed</servlet-name>
<servlet-class>eng.ku.sku.exceed_vote.knt.Controller</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>exceed</servlet-name>
<url-pattern>/addtext</url-pattern>
Controller.java Controller.java
package eng.ku.sku.exceed_vote.knt;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
@WebServlet("/addtext")
public class Controller extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response); // Same as doPost()
}
@Override
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// Retrieve the current session, or create a new session if no session exists.
HttpSession session = request.getSession(true);
System.out.println("HIIEER");
// Retrieve the shopping cart of the current session.
// For dispatching the next Page
String nextPage = "";
String todo = request.getParameter("todo");
// Dispatch to checkout.jsp
nextPage = "/checkout.jsp";
response.sendRedirect(nextPage);
return;
}
}
I read a lot of other topics but didnt find a solution. 我阅读了很多其他主题,但没有找到解决方案。 I hope u can help me :)
我希望你能帮助我:)
Okay it was a wrong config of Tomcat. 好吧,这是Tomcat的错误配置。
It didn't sync the project changes. 它没有同步项目的变化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.