正如软件有他的皮肤一样,我们的系统也有自己的皮肤,如果我们的应用系统可以让不同的客户选择自己喜欢的风格,那么我们将会感到无比的开心,难道不是吗?
可以更加容易的使用标记库,更轻松的开发出系统风格一致的系统
Struts基于mvc2的frameWork广泛的应用的j2ee开发领域中,
? configure struts for the webapp
? configure the struts-layout treeview and sort action (just copy the corresponding lines of the struts-config file of the example application)
? copy the struts-layout.jar file into the WEB-INF/lib directory.
? declare the struts-layout tld file in the web.xml file
? copy the menu.jar file from the struts-layout example application into the WEB-INF/lib directory.
? put a version of the common BeanUtils library in the WEB-INF/lib directory if using struts 1.0
? copy the struts-layout.tld file into the WEB-INF directory.
? copy the files in the config and images directory of the struts-layout example application in your new webapp.
? if forward to Tiles definition will be used with sorting or paging on the server, the struts-layout request processor
example:
...
<layout:form action="..." styleClass="FORM"
<layout:grid cols="3"
<layout:text key="Field 1" property="username1"/
<layout:text key="Field 2" property="username2"/
<layout:text key="Field 3" property="username3"/
<layout:text key="Field 4" property="username4"/
<layout:text key="Field 5" property="username5"/
<layout:text key="Field 6" property="username6"/
</layout:grid
<layout:grid cols="2"
<layout:text key="Text input field 7" property="username7"/
<layout:text key="Text input field 8" property="username8"/
<layout:text key="Text input field 9" property="username9"/
<layout:text key="Text input field 10" property="username10"/
</layout:grid
</layout:form
...
...
<layout:form action="..." styleClass="FORM"
<layout:row
<layout:collection name="users" styleClass="FORM"
<layout:collectionItem title="users.login" property="login"/
<layout:collectionItem title="users.firstname" property="firstname"/
<layout:collectionItem title="users.lastname" property="lastname"/
<layout:collectionItem title="users.society" property="society"/
</layout:collection
<layout:column
<layout:text key="Field 1" property="username1"/
<layout:text key="Field 2" property="username2"/
<layout:text key="Field 3" property="username3"/
</layout:column
</layout:row
</layout:form
...
...
<layout:form action="..." styleClass="FORM"
<layout:grid cols="2"
<layout:collection name="users" styleClass="FORM" length="3"
<layout:collectionItem title="users.login" property="login"/
<layout:collectionItem title="users.firstname" property="firstname"/
<layout:collectionItem title="users.lastname" property="lastname"/
<layout:collectionItem title="users.society" property="society"/
</layout:collection
<layout:column
<layout:text key="Field 1" property="username"/
<layout:text key="Field 2" property="username"/
<layout:text key="Field 3" property="username"/
</layout:column
</layout:grid
<layout:space/
<layout:grid cols="3"
<layout:text key="Field 6" property="username"/
<layout:text key="Field 7" property="username"/
<layout:text key="Field 8" property="username"/
<layout:space/
<layout:text key="Field 9" property="username"/
<layout:space/
</layout:grid
</layout:form
...
jsp page:
[
<%@ page language="java" %
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %
<html:html locale="true"
<head
<title<bean:message key="logon.title"/</title
<html:base/
</head
<body bgcolor="white"
<html:errors/
<html:form action="/logon" focus="username"
<table border="0" width="100%"
<tr
<th align="right"
<bean:message key="prompt.username"/
</th
<td align="left"
<html:text property="username" size="16" maxlength="16"/
</td
</tr
<tr
<th align="right"
<bean:message key="prompt.password"/
</th
<td align="left"
<html:password property="password" size="16" maxlength="16"
redisplay="false"/
</td
</tr
<tr
<td align="right"
<html:submit property="submit" value="Submit"/
</td
<td align="left"
<html:reset/
</td
</tr
</table
</html:form
</body
</html:html
]
layout page:
[
<%@ page language="java" %
<%@ taglib uri="/WEB-INF/struts-layout.tld" prefix="layout" %
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %
<layout:html locale="true" styleClass="FORM"
<html:errors property="org.apache.struts.action.GLOBAL_ERROR"/
<layout:form action="/logon.do" focus="username" key="logon.title" styleClass="FORM"
<layout:field key="prompt.username" property="username" size="16" maxlength="16" isRequired="true" styleClass="LABEL"/
<layout:field key="prompt.password" property="password" size="16" maxlength="16" type="password" styleClass="LABEL" isRequired="true"/
<layout:formActions
<layout:submit property="submit" value="Submit"/
<layout:reset/
</layout:formActions
</layout:form
</layout:html
,使用layout可以更加容易的开发!