SSH实例(6)

时间:2023-03-09 09:32:14
SSH实例(6)

在WebContent文件夹下新建query.jsp和save.jsp文件。

query.jsp:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>显示课程信息</title>
</head>
<body>
<center>
<h1>课程信息</h1>
<table border="1" width="800" style="table-layout:fixed"> <tr style="background-color:rgb(255,255,0)">
<th width="10%">序号</th>
<th width="20%">课程名称</th>
<th width="50%">课程说明</th>
<th width="10%">是否删除</th>
<th width="10%">是否修改</th>
</tr>
<s:iterator value="#request.claslist" id="st" status="sst">
<tr>
<td align="center"><s:property value="#sst.index+1"/> </td>
<td align="center"><s:property value="#st.name"/> </td>
<td align="left"><s:property value="#st.comment"/> </td>
<td align="center"><a href="userdelete.action?id=<s:property value='#st.id'/>">删除</a></td>
<td align="center"><a href="update.jsp?id=<s:property value='#st.id'/>">更新</a></td>
</tr>
</s:iterator>
</table>
<br>
<a href="save.jsp">添加课程</a>
</center>
</body> </html>

save.jsp:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>添加课程</title>
</head>
<body>
<center>
<s:form action="clas" method="post" >
<tr>
<td colspan="2" align="center">
<h1><s:text name="欢迎添加课程"/></h1><br/>
<s:property value="exception.message"/>
</td>
</tr>
<s:textfield name="clas.name" key="课程名称"
tooltip="Enter class name!" required="true"></s:textfield>
<s:textfield name="clas.comment" key="课程介绍"
tooltip="Enter the comment!" required="true"></s:textfield>
<s:submit value="提交"/>
<s:set/>
</s:form>
</center>
</body>
</html>