当前位置:   article > 正文

JavaWeb课程设计-学生信息管理系统(Jsp+Servlet+MySql)_学生信息管理系统javaweb课程设计

学生信息管理系统javaweb课程设计

《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》点击传送门,即可获取!

}

3. 实现业务层(Service)

编写业务层接口:

/**

  • 用户管理的业务接口

*/

public interface UserService {

}

实现业务层接口:

public class UserServiceImpl implements UserService {

private UserDao dao = new UserDaoImpl();

}

4.实现表现层功能

编写表现层:

@WebServlet(“/loginServlet”)

public class LoginServlet extends HttpServlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

/*

  • Code

*/

}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

this.doPost(request, response);

}

}

5.由于表现层Servlet太多,我们可以做简单的提取

编写BaseServlet类,然后由其他servlet继承

public class BaseServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

try {

// 获取请求标识

String methodName = request.getParameter(“method”);

// 获取指定类的字节码对象

Class<? extends BaseServlet> clazz = this.getClass();//这里的this指的是继承BaseServlet对象

// 通过类的字节码对象获取方法的字节码对象

Method method = clazz.getMethod(methodName, HttpServletRequest.class, HttpServletResponse.class);

// 让方法执行

method.invoke(this, request, response);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

5.编写对应的前端页面:以user_login.jsp为例

<%@ page contentType=“text/html;charset=UTF-8” language=“java” %>

<%@taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core” %>

管理员登录

管理员登录


×

${login_msg

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/757523
推荐阅读
相关标签
  

闽ICP备14008679号