基于注解的ssm crud的项目03

2023-06-27 16:34:50 浏览数 (2)

jsp界面:

register.jsp:

<%

String path = request.getContextPath();

String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() path "/";

application.setAttribute("basePath",basePath);

%>

<html>

<head>

<base href="<%=basePath%>" />

<title>员工注册</title>

</head>

<body>

<a href="${basePath}emp/emps">查询所有</a>

<form action="${basePath}emp/emps" method="POST">

<table border="2" align="center">

<!-- <tr>

<th>编号</th>

<td><input type="text" name="id"></td>

</tr> -->

<tr>

<th>姓名</th>

<td><input type="text" name="name"></td>

</tr>

<tr>

<th>薪水</th>

<td><input type="text" name="sal"></td>

</tr>

<tr>

<th>性别</th>

<td>

<input type="radio" name="sex" value="男"/>男

<input type="radio" name="sex" value="女" checked/>女

</td>

</tr>

<tr>

<td colspan="2" align="center">

<input type="submit" value="注册"/>

</td>

</tr>

</table>

</form>

</body>

</html>

list.jsp:

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

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%

String path = request.getContextPath();

String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() path "/";

application.setAttribute("basePath",basePath);

%>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<base href="<%=basePath%>" />

<title>所有</title>

<script type="text/javascript" src="${basePath}js/jquery-1.11.1.min.js"></script>

<script type="text/javascript">

$(function(){

$(".delete").click(function(){

var href=$(this).attr("href");

$("form").attr("action",href).submit();

return false;

});

});

</script>

</head>

<body>

<form action="" method="post">

<input type="hidden" name="_method" value="DELETE">

</form>

<table style="padding: 0.5em 0.5em;">

<thead>

<tr>

<th>姓名</th>

<th>价格</th>

<th>年龄</th>

<th>日期</th>

<th>操作</th>

</tr>

</thead>

<tbody>

<c:forEach var="lall" items="${requestScope.listAll}" >

<tr>

<td>

${lall.name }

</td>

<td>

${ lall.sal }

</td>

<td>

${ lall.sex }

</td>

<td>

<fmt:formatDate value="${lall.date}" type="both"/>

</td>

<td>

<a href="${basePath}emp/emps/${lall.id}">编辑</a>

&nbsp;&nbsp;

<a href="${basePath}emp/emps/${lall.id}" class="delete">删除</a>

</td>

</tr>

</c:forEach>

</tbody>

</table>

</body>

</html>

updatelist.jsp

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

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%

String path = request.getContextPath();

String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() path "/";

application.setAttribute("basePath",basePath);

%>

<!DOCTYPE html>

<html>

<head>

<base href="<%=basePath%>" />

<meta charset="UTF-8">

<title>编辑-》查看</title>

</head>

<body>

<form action="${basePath}emp/emps" name="form1" method="POST">

<input type="hidden" name="_method" value="PUT"/>

<table>

<tbody>

<tr>

<td>姓名:</td>

<td>

<input name="name" value="${emps.name}" type="text">

</td>

</tr>

<tr>

<td>价格:</td>

<td>

<input name="sal" value="${emps.sal}" type="text">

</td>

</tr>

<tr>

<td>年龄:</td>

<td>

<input name="sex" value="${emps.sex}" type="text">

</td>

</tr>

<tr>

<td colspan="2">

<input name="date" value="${emps.date}" type="hidden">

<input name="id" value="${emps.id}" type="hidden">

<input type="submit" value="保存">

</td>

</tr>

</tbody>

</table>

</form>

</body>

</html>

0 人点赞