我尝试发送一些数据,但似乎无法清除控制器或无法处理请求。
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
<?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
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;
}
}
我阅读了很多其他主题,但没有找到解决方案。我希望你能帮助我:)。
答案 0 :(得分:0)
好吧,这是Tomcat的错误配置。
它没有同步项目更改。