🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 学生信息采集系统 >1.首先打开Eclipse,创建一个Dynamic Web Project(动态web项目) ![](http://h.yiniuedu.com/4c000cde986752f82fa37adbcf905d47) ![](http://h.yiniuedu.com/58862ee124d3b6c9ab0dfb7e84220c95) >2.在WebContent下创建一个index.jsp页面,添加如下代码: ![](http://h.yiniuedu.com/0452068a38591db84f6fb371ff38ea64) ``` <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>学生信息采集系统</title> </head> <body> <center> <form action="StudentServlet" method="post"> 学生信息采集页面</br> 年级:<input type="text" name="grade"/></br> 班级:<input type="text" name="class"/></br> 专业:<input type="text" name="pro"/></br> 学号:<input type="text" name="no"/></br> 姓名:<input type="text" name="stuName"/></br> 手机号:<input type="text" name="MobileNo"/></br> 密码:<input type="password" name="pwd"/></br> <input type="submit" /> </form> </center> </body> </html> ``` >3.在src下创建一个StudentServlet,添加如下代码: ![](http://h.yiniuedu.com/bbc47e1406ca68f5d68c8d350488b8a9) ``` package com.baish.controller; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/StudentServlet") public class StudentServlet extends HttpServlet { private static final long serialVersionUID = 1L; public StudentServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String grade = request.getParameter("grade"); String classes = request.getParameter("class"); String pro = request.getParameter("pro"); String no = request.getParameter("no"); String stuName = request.getParameter("stuName"); String MobileNo = request.getParameter("MobileNo"); String pwd = request.getParameter("pwd"); System.out.println(grade+":"+classes+":"+pro+":" +no+":"+stuName+":"+MobileNo+":"+pwd); } } ``` >4.启动tomcat,访问index.jsp页面 http://localhost:9090/myfirstweb/index.jsp 并在页面输入如下数据,点击提交按钮。 ![](http://h.yiniuedu.com/89562455fafdcef86fed805b3b12c114) >5.输入测试数据,在后端console窗口查看前端提交的数据 ![](http://h.yiniuedu.com/88f06aaff36342e04d8d0dcc6c499fa6) ![](http://h.yiniuedu.com/bbaf13a6d1c689b8ba95eda5fd02d962)