注册界面.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isELIgnored="false"%>
t<hml>
<body>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入 Bootstrap -->
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<h1>
基于SSM框架的管理系统:简单实现增、删、改、查。
</h1>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<h1>
<small>新增用户</small>
</h1>
</div>
</div>
</div>
<form action="${pageContext.request.contextPath}/user/save1.do"
method="post">
用 户 id:<input type="text" name="id" disabled="true" value="自动生成"><br><br><br>
用户姓名:<input type="text" name="username"><br><br><br>
用户密码:<input type="text" name="password"><br><br><br>
<input type="submit" value="添加" >
</form>
</div>
</body>
</html>
储存注册信息
@RequestMapping("save.do")
public String insert(TbUser user){
userService.insert(user);
return "redirect:FindAll.do";
}
登录.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Login</title>
</head>
<body>
<h2><a href="${pageContext.request.contextPath}/user/FindAll.do">查询所以用户</a></h2>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<h1>
基于SSM框架的管理系统:简单实现增、删、改、查。
</h1>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<h1>
<small>新增用户</small>
</h1>
</div>
</div>
</div>
<form action="${pageContext.request.contextPath}/user/FindOne1.do"
method="post">
用户姓名:<input type="text" name="username"><br><br><br>
用户密码:<input type="text" name="password"><br><br><br>
<input type="submit" value="登录" >
</form>
</div>
</body>
</html>
查询用户信息
@RequestMapping("FindOne1.do")
public String FindOne1(HttpServletRequest request){
String username = request.getParameter("username");
String password = request.getParameter("password");
List<TbUser> user = userService.FindOne1(username,password);
if(user.size()==0){
return "login";
}
return "redirect:FindAll.do";
}
dao包和service包写入
List<TbUser> FindOne1(String username,String password);
@Override
public List<TbUser> FindOne1(String username,String password) {
return userDao.FindOne1(username,password);
}
Sql语句
<select id="FindOne1" resultType="com.zhongruan.bean.TbUser">
SELECT * FROM tb_user where username = #{0} and password = #{1}
<select>