MVC三层架构(代码整体以此分层编写)
整体的流程与代码编写思路:
建议是从后往前
写,便于调试与debug,先编写Dao层
,主要负责与数据库交互,编写sql语句等。然后编写Servicce层
,主要负责调用Dao层,再编写Servlet层
,其也是主要调用Service和前端的一些数据交互,比如resquet和response等。
基本架构
项目搭建准备工作
1- 4
5 创建项目包结构
6-7
登录功来源gaodaimacom搞#^代%!码网能实现
1.编写前端页面 login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>系统登录 - 超市订单管理系统</title> <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath }/css/style.css" rel="external nofollow" /> <script type="text/javascript"> /* if(top.location!=self.location){ top.location=self.location; } */ </script> </head> <body class="login_bg"> <section class="loginBox"> <header class="loginHeader"> <h1>超市订单管理系统</h1> </header> <section class="loginCont"> <form class="loginForm" action="${pageContext.request.contextPath }/login.do" name="actionForm" id="actionForm" method="post" > <div class="info">${error }</div> <div class="inputbox"> <label for="userCode">用户名:</label> <input type="text" class="input-text" id="userCode" name="userCode" placeholder="请输入用户名" required/> </div> <div class="inputbox"> <label for="userPassword">密码:</label> <input type="password" id="userPassword" name="userPassword" placeholder="请输入密码" required/> </div> <div class="subBtn"> <input type="submit" value="登录"/> <input type="reset" value="重置"/> </div> </form> </section> </section> </body> </html>
2.设置首页
<!--设置欢迎界面--> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list>