用idea製做Javaweb程序遇到的過程

index.jsphtml

<%--
  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" %>
<html>
  <head>
    <title>客戶</title>
  </head>
  <body>
  <form method="post" action="/save">
    客戶姓名:<input type="text" name="name"><br>
    客戶年齡:<input type="text" name="age"><br>
    <input type="submit" name="提交">
  </form>
  </body>
</html>

 

save.classjava

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:web

解決方案:瀏覽器

瀏覽器設置的問題tomcat

出現問題2:jsp

图片说明

試過不少方法,也從cmd中終止了程序,可是仍是不能夠,最後個人解決方法是將使用的tomcat刪除,從新導入tomcat。post

相關文章
相關標籤/搜索