上一篇博客,简单的实现了spring-mvc的注册功能,本期我们将继续完善ssm项目,具体的实体类,service和controller可以看上一篇ssm配置并简单的实现
jsp文件
modify.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>修改</title>
</head>
<body>
<form action="/user/update.do">
<input name="id" value="${user.id}" type="hidden">
<div>
<label for="name">用户名</label>
<input name="name" type="text" id="name" value="${user.name}">
</div>
<div>
<label for="password">密码</label>
<input name="password" type="text" id="password" value="${user.password}">
</div>
<div>
<input type="submit" value="提交">
</div>
<a href="javascript:window.history.go(-1)">返回</a>
</form>
</body>
</html>
main.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Created by IntelliJ IDEA.
User: scz
Date: 2020/7/2
Time: 9:22
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>列表</title>
</head>
<body>
<div>
<form action="/user/findAll.do">
<input id="name" type="search" name="name" value="${name}">
<button onclick="form.submit()">搜索</button>
</form>
<table>
<thead>
<try>
<th>Id</th>
<th>用户名</th>
<th>密码</th>
<th>操作</th>
</try>
</thead>
<tbody>
<c:forEach items="${userList}" var="user">
<tr>
<td>${user.id}</td>
<td>${user.name}</td>
<td>${user.password}</td>
<td>
<a href="${pageContext.request.contextPath}/user/delete.do?id=${user.id}">删除</a>
<a href="${pageContext.request.contextPath}/user/findById.do?id=${user.id}">修改</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</body>
</html>
index.jsp
<%--
Created by IntelliJ IDEA.
User: scz
Date: 2020/6/30
Time: 19:09
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Login</title>
</head>
<body>
<form action="/user/login.do" method="post">
name:<input name="name" type="text">
password:<input name="password" type="password">
<input type="submit" value="login">
</form>
<a href="add.jsp">注册</a>
<a href="/user/findAll.do?name">查看数据</a>
</body>
</html>
运行结果
执行删除后
执行修改后