1. 在WEB-INF下建立文件夹themes/mytheme(也即可以在java源代码目录下建立与struts2的源代码相当的模板目录,这样就不用指定了)
2. 配置struts.properties,指定使用的theme(此处可选)
struts.ui.theme = mytheme
struts.ui.templateDir = /WEB-INF/themes
3. fielderror.ftl 校验域,内容自定义
示例如下:
<#if fieldErrors??><#t/>
<#assign eKeys = fieldErrors.keySet()><#t/>
<#assign eKeysSize = eKeys.size()><#t/>
<#assign haveMatchedErrorField=false><#t/>
<#if (fieldErrorFieldNames?size > 0) ><#t/>
<#list fieldErrorFieldNames as fieldErrorFieldName><#t/>
<#list eKeys as eKey><#t/>
<#if (eKey = fieldErrorFieldName)><#t/>
<#assign haveMatchedErrorField=true><#t/>
<#assign eValue = fieldErrors[fieldErrorFieldName]><#t/>
<#list eValue as eEachValue><#t/>
<span class="fielderror"><#if parameters.escape>${eEachValue!?html}<#else>${eEachValue!}</#if></span>
</#list><#t/>
</#if><#t/>
</#list><#t/>
</#list><#t/>
</#if><#t/>
</#if><#t/>