12.16.3 视图组件
撰写公告的请求在通过权限验证之后,将根据配置文件被转发到ToNewNotice代表的路径,即进入撰写公告页面/user/newnotice.jsp。此页面在表单中包含一个用于填写新公告的表格,当输入信息完成之后,提交表单将发出newnotice.do请求。下面是该页面的源代码。
<%@ page contentType="text/html;charset=gb2312" language="java"%> <%@ include file="/common/taglibs.jsp"%> <html:html> <head> <title> <bean:message key="InsertNewNotice.jsp.title" /> </title> </head> <link href="images/myStyleClass.css" rel="stylesheet" type="text/css"> <body> <html:errors/>标签用于显示包含于ActionErrors的ActionMessage 对象中所封装的信息。 <html:errors /> //生成HTML中的form标签,其中的action属性设定该表单将被提交到的URL, //focus属性设置初始时焦点所在的元素的名字。 //当用户单击“插入”按钮时,即向服务器中发出提交newnotice.do请求以交给相应的Action处理 <html:form action="/newnotice.do" focus="title"> <center> 生成一个三行两列的表格。 <table width="72%" border="0" align="center" cell padding="2" cellspacing="2"> //各个用于输入信息的组件。它们的property值分别是title、content //它们与ActionForm Bean的属性名需要严格对应。 //该行第一列是一段文字,它从预定义的资源中获取相应关键 字的对应字符串,为“标题” //第二列是一个HTML输入表单中类型为text的<Input>标签 <tr> <td width="40%" align="right"> <bean:message key="InsertNewNotice.title" /> </td> <td width="60%"> <html:text property="title" size="70" /> </td> </tr> //该行第一列是一段文字,它从预定义的资源中获取相应关 键字的对应字符串,为“内容”。 //第二列是一个HTML输入表单中类型为textarea的<Input>标签 <tr> <td align="right"> <bean:message key="InsertNewNotice.content" /> </td> <td> <html:textarea property="content" cols="60" rows="12" /> </td> </tr> //该行第一列是一个HTML输入表单中类型为submit的<Input>标签, //其显示文字为从预定义的资源中获取InsertNewNotice.submit关键字的对应 字符串,为“插入”, //第二列是一个HTML输入表单中类型为reset的<Input>标签; //其显示文字为从预定义的资源中获取“InsertNewNotice.reset” 关键字的对应 字符串,为“重置” <tr> <td align="right"> <html:submit property="submit"> <bean:message key="InsertNewNotice.insert" /> </html:submit> </td> <td align="left"> <html:reset> <bean:message key="InsertNewNotice.reset" /> </html:reset> </td> </tr> </table> </center> </html:form> <%@ include file="/common/footer.jsp"%> </body> </html:html> |
【责任编辑:
夏书 TEL:(010)68476606】