我的工程目录
一、前端的页面
list.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="/css/bootstrap.css"></link>
</head>
<body>
<div class="with:80%">
<table class="table table-hover">
<thead>
<tr align="center">
<td colspan="9">
<form action="/listall" method="post">
<label>查询条件:</label>
<input type="text" name="userName" id="userName" placeholder="输入姓名">
<input type="submit" value="查询" class="btn btn-info" />
</form>
</td>
</tr>
<tr>
<th>编号</th>
<th>用户名</th>
<th>密码</th>
<th>邮箱</th>
<th>头像</th>
<th>编辑</th>
<th>删除</th>
</tr>
</thead>
<tbody>
<c:set var="index" value="0" />
<c:forEach var="i" items="${list}" >
<c:set var="index" value="${index+1}" />
<tr>
<th >${index}</th>
<td >${i.userName}</td>
<td >${i.passWord}</td>
<td >${i.email}</td>
<td ><img src="/upload/${i.filepath }" width="100" height="100"></td>
<td><a href="/toEdit?id=${i.id }" class="btn btn-info">edit</a></td>
<td><a href="javascript:void(0)" οnclick="del(${i.id })" class="btn btn-info">delete</a></td>
</tr>
</c:forEach>
</tbody>
</table>
<script type="text/javascript">
function del(id){
if(confirm("确认删除id="+id))
location.href="/del?id="+id;
}
</script>
</div>
<div class="form-group">
<div class="col-sm-2 control-label">
<a href="userAdd.jsp" class="btn btn-info">添加</a>
</div>
</div>
</body>
</html>
userAdd.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="/css/bootstrap.css"></link>
</head>
<body class="container">
<br/>
<h1>用户添加</h1>
<br/><br/>
<div class="with:80%">
<form class="form-horizontal" action="/add" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="userName" class="col-sm-2 control-label">用户名</label>
<div class="col-sm-10">
<i