index.jsp
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2018/10/29 Time: 11:47 To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %>客户
save.class
package cn.sm1234.web;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;@WebServlet(name = "save",urlPatterns = "/save")public class save extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request,response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); String name=request.getParameter("name"); String age = request.getParameter("age"); System.out.println(name+","+age); }}
遇到的问题1:
解决方案:
浏览器设置的问题
出现问题2:
试过很多方法,也从cmd中终止了程序,但是还是不可以,最后我的解决方法是将使用的tomcat删除,重新导入tomcat。