国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Java > 正文

struts2中simple主題下 標簽默認樣式的移除方法

2024-07-14 08:42:31
字體:
來源:轉載
供稿:網友

前言

當在我們注冊用戶時,如果給前臺的提示是用戶名重復并且用戶名太長時,就會要往action里面添加多個errors,這時到前臺怎么把它依次拿出來

下面話不多說了,來一起看看詳細的介紹吧

方法如下

①找到配置文件

struts2-core-2.3.35.jar/template/simple/fielderror.ftl(不同版本的文件路徑大同小異)

②創建新的文件包并拷貝文件

在項目根目錄下創建template.simple并將fielderror.ftl拷貝過來

此時根目錄下的fielderror.ftl文件優先權大于默認的fielderror.ftl文件

③修改拷貝過來的fielderror.ftl文件

修改前文件如下

<#--/* * $Id$ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */--><#if fieldErrors??><#t/> <#assign eKeys = fieldErrors.keySet()><#t/> <#assign eKeysSize = eKeys.size()><#t/> <#assign doneStartUlTag=false><#t/> <#assign doneEndUlTag=false><#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/>     <#if (haveMatchedErrorField && (!doneStartUlTag))><#t/>     <ul<#rt/>      <#if parameters.id?has_content>        id="${parameters.id?html}"<#rt/>      </#if>      <#if parameters.cssClass?has_content>        class="${parameters.cssClass?html}"<#rt/>       <#else>        class="errorMessage"<#rt/>      </#if>      <#if parameters.cssStyle?has_content>        style="${parameters.cssStyle?html}"<#rt/>      </#if>       >      <#assign doneStartUlTag=true><#t/>     </#if><#t/>     <#list eValue as eEachValue><#t/>      <li><span><#if parameters.escape>${eEachValue!?html}<#else>${eEachValue!}</#if></span></li>     </#list><#t/>    </#if><#t/>   </#list><#t/>  </#list><#t/>  <#if (haveMatchedErrorField && (!doneEndUlTag))><#t/>  </ul>   <#assign doneEndUlTag=true><#t/>  </#if><#t/>  <#else><#t/>  <#if (eKeysSize > 0)><#t/>  <ul<#rt/>   <#if parameters.cssClass?has_content>     class="${parameters.cssClass?html}"<#rt/>    <#else>     class="errorMessage"<#rt/>   </#if>   <#if parameters.cssStyle?has_content>     style="${parameters.cssStyle?html}"<#rt/>   </#if>    >   <#list eKeys as eKey><#t/>    <#assign eValue = fieldErrors[eKey]><#t/>    <#list eValue as eEachValue><#t/>     <li><span><#if parameters.escape>${eEachValue!?html}<#else>${eEachValue!}</#if></span></li>    </#list><#t/>   </#list><#t/>  </ul>  </#if><#t/> </#if><#t/></#if><#t/>

將<ul></ul>、<li></li>、<span></span>刪除

修改后文件如下

<#--/* * $Id$ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */--><#if fieldErrors??><#t/> <#assign eKeys = fieldErrors.keySet()><#t/> <#assign eKeysSize = eKeys.size()><#t/> <#assign doneStartUlTag=false><#t/> <#assign doneEndUlTag=false><#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/>     <#if (haveMatchedErrorField && (!doneStartUlTag))><#t/>           <#assign doneStartUlTag=true><#t/>     </#if><#t/>     <#list eValue as eEachValue><#t/>      <#if parameters.escape>${eEachValue!?html}<#else>${eEachValue!}</#if>     </#list><#t/>    </#if><#t/>   </#list><#t/>  </#list><#t/>  <#if (haveMatchedErrorField && (!doneEndUlTag))><#t/>     <#assign doneEndUlTag=true><#t/>  </#if><#t/>  <#else><#t/>  <#if (eKeysSize > 0)><#t/>     <#list eKeys as eKey><#t/>    <#assign eValue = fieldErrors[eKey]><#t/>    <#list eValue as eEachValue><#t/>     <#if parameters.escape>${eEachValue!?html}<#else>${eEachValue!}</#if>    </#list><#t/>   </#list><#t/>    </#if><#t/> </#if><#t/></#if><#t/>

重啟tomcat

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對VeVb武林網的支持。


注:相關教程知識閱讀請移步到JAVA教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 专栏| 广灵县| 尼勒克县| 称多县| 双牌县| 紫阳县| 昌图县| 汪清县| 五寨县| 涿州市| 韩城市| 沭阳县| 苍溪县| 孟津县| 漠河县| 昌邑市| 岐山县| 伊通| 五河县| 镇江市| 鹤壁市| 广南县| 克拉玛依市| 壶关县| 淮南市| 瓦房店市| 财经| 元阳县| 临汾市| 革吉县| 梅河口市| 美姑县| 连江县| 怀宁县| 海南省| 米泉市| 精河县| 临高县| 芜湖县| 阿克陶县| 台北市|