• 学生信息系统servlet层


    package org.student.servlet;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    
    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 org.student.service.StudentService;
    
    import ogr.student.entity.Student;
    
    /**
     * Servlet implementation class AddStudentServlet
     */
    @WebServlet("/AddStudentServlet")
    public class AddStudentServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
        public AddStudentServlet() {
            super();
            
        }
    
        
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            
            int num = Integer.parseInt(request.getParameter("snum"));
            String name=request.getParameter("sname");
            int age = Integer.parseInt(request.getParameter("sage"));
            String adress = request.getParameter("sadress");
            Student student = new Student(num,age,name,adress);
            
            
            StudentService stu=new StudentService();
            boolean rescult = stu.addStudent(student);
            
            
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            PrintWriter out = response.getWriter();
            if(rescult) {
                out.println("增加成功");
            }else {
                out.println("增加失败");
            }
        }
    
        
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            
        }
    
    }
  • 相关阅读:
    MySQL组提交(group commit)
    MySQL 热快问题解决
    Mysql 高可用集群PXC
    向量的点积(标量积、内积)
    BitmapData.threshold()方法
    Unity 自定义导入时切割Sprite
    匀变速直线运动的速度与位移的关系
    1.1.2 三角形余弦定理
    ccc切割刚体
    Unity 获取指定资源目录下的所有文件
  • 原文地址:https://www.cnblogs.com/jz-no-bug/p/14230080.html
Copyright © 2020-2023  润新知