简单的struts应用开发(5)
时间:2011-08-05
第六步:建立JSP视图页面 (主要有两个jsp文件. 添加页面. adduser.jsp 查看页面 viewuser.jsp)
adduser.jsp
<%@ taglib uri="/Web-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ page contentType="text/html; charset=gb2312" %>
<html:html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>
adduser
</title>
</head>
<body>
<h1> </h1>
<p>
<html:form action="/user1Action.do" method="POST">
<html:hidden property="action"/>
<br>
部门:
<html:select property="dep">
<html:options collection="dep" property="id" labelProperty="name1"/>
</html:select>
<br>
ID:
<logic:equal name="userActionForm" property="action" scope="request" value="add">
<html:text property="user_id"/>
</logic:equal>
<logic:equal name="userActionForm" property="action" scope="request" value="edit">
<html:text property="user_id" readonly="true"/>
</logic:equal>
<br>
名字:<html:text property="user_name"/>
<br>
电话:<html:text property="tel"/>
<br>
<html:submit property="submit" value="Submit"/><br>
<html:reset value ="Reset"/>
</html:form>
</body>
</html:html>
viewuser.jsp
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ page contentType="text/html; charset=GBK" %>
<html:html>
<head>
<title>
viewuser
</title>
</head>
<body>
<div align="center"><a href="userAction.do?action=add">add </a></div>
<table width="60%" border="1" align="center">
<tr bgcolor="#CCCCCC">
<td>ID</td>
<td>user_name</td>
<td>dep</td>
<td>tel</td>
<td>modify</td>
<td>del</td>
</tr>
<logic:iterate name="rs" id="user" scope="request" type="Java.util.HashMap">
<tr>
<td><bean:write name="user" property="user_id&q
|