01 | package com.sxh.controller; |
02 |
03 | import java.io.IOException; |
04 | import java.sql.SQLException; |
05 |
06 | import javax.servlet.ServletException; |
07 | import javax.servlet.annotation.WebServlet; |
08 | import javax.servlet.http.HttpServlet; |
09 | import javax.servlet.http.HttpServletRequest; |
10 | import javax.servlet.http.HttpServletResponse; |
11 |
12 | import com.sxh.pojo.Student; |
13 | import com.sxh.service.AdminService; |
14 | import com.sxh.service.AdminServiceImpl; |
15 |
16 | /** |
17 | * Servlet implementation class AddStudent |
18 | */ |
19 | @WebServlet ( "/AddStudent" ) |
20 | public class AddStudent extends HttpServlet { |
21 | private static final long serialVersionUID = 1L; |
22 | |
23 | private AdminService adminService= new AdminServiceImpl(); |
24 | /** |
25 | * @see HttpServlet#HttpServlet() |
26 | */ |
27 | public AddStudent() { |
28 | super (); |
29 | // TODO Auto-generated constructor stub |
30 | } |
31 |
32 | /** |
33 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) |
34 | */ |
35 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
36 | // TODO Auto-generated method stub |
37 | doPost(request, response); |
38 | } |
39 |
40 | /** |
41 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) |
42 | */ |
43 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
44 | // TODO Auto-generated method stub |
45 | String studentId=request.getParameter( "studentId" ); |
46 | String name=request.getParameter( "name" ); |
47 | String sex=request.getParameter( "sex" ); |
48 | String password=request.getParameter( "password" ); |
49 | String clazz=request.getParameter( "clazz" ); |
50 | |
51 | Student student= new Student(); |
52 | student.setStudentId(studentId); |
53 | student.setName(name); |
54 | student.setSex(sex); |
55 | student.setPassword(password); |
56 | student.setClazz(clazz); |
57 | |
58 | System.out.println(student); |
59 | try { |
60 | if (adminService.AddStudent(student)== 1 ) { |
61 | response.getWriter().write( "success" ); |
62 | } else { |
63 | response.getWriter().write( "fail" ); |
64 | } |
65 | } catch (SQLException e) { |
66 | // TODO Auto-generated catch block |
67 | e.printStackTrace(); |
68 | } |
69 | |
70 | } |
71 |
72 | } |

TY0165 LV20
2024年6月18日
微信网友_6906962132258816 LV7
2024年3月14日
zeng1206 LV7
2023年12月26日
蹇金金 LV7
2023年11月6日
刘洋66666 LV1
2023年10月3日
微信网友_6625276664238080 LV1
2023年8月28日
jhmajxb LV3
2023年5月27日
不停的奔跑 LV20
2023年4月23日
kk1031 LV8
2023年4月13日
彩色天空 LV5
2023年4月8日

Maomaoyun
6月10日
暂无贡献等级
微信网友_6979151039729664 LV2
4月4日
kkkxyh LV13
2月11日
ma406805131 LV19
2024年12月26日
1565984
2024年12月20日
暂无贡献等级
李清清 LV2
2024年11月6日
13543528515 LV8
2024年11月2日
文巾方
2024年10月30日
暂无贡献等级
zwn258000
2024年10月24日
暂无贡献等级
linhua LV1
2024年9月29日