欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

struts2中simple主題下<s:fieldError>標簽默認樣式的移除方法

 更新時間:2018年10月11日 08:40:54   作者:努力學習的IT萌新  
這篇文章主要給大家介紹了關(guān)于struts2中simple主題下<s:fieldError>標簽默認樣式的移除方法,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考借鑒,下面隨著小編來一起學習學習吧

前言

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

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

方法如下

①找到配置文件

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

②創(chuàng)建新的文件包并拷貝文件

在項目根目錄下創(chuàng)建template.simple并將fielderror.ftl拷貝過來

此時根目錄下的fielderror.ftl文件優(yōu)先權(quán)大于默認的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

總結(jié)

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

相關(guān)文章

  • java中的類為什么只能用public修飾?

    java中的類為什么只能用public修飾?

    這篇文章主要介紹了java中的類為什么只能用public修飾,幫助大家更好的理解和使用Java,感興趣的朋友可以了解下
    2020-12-12
  • Maven和IntelliJ IDEA搭建多模塊微服務的實現(xiàn)

    Maven和IntelliJ IDEA搭建多模塊微服務的實現(xiàn)

    本文主要介紹了Maven和IntelliJ IDEA搭建多模塊微服務的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2024-05-05
  • Java中常見的4種限流算法詳解

    Java中常見的4種限流算法詳解

    這篇文章主要介紹了Java中常見的4種限流算法詳解,FixedWindowRateLimiter 類表示一個固定窗口限流器,使用 limit 和 interval 參數(shù)分別表示限制請求數(shù)量和時間間隔,缺點是短時間內(nèi)可能會流量翻倍,需要的朋友可以參考下
    2023-12-12
  • javaweb 項目初始配置的方法步驟

    javaweb 項目初始配置的方法步驟

    本文主要介紹了javaweb 項目初始配置的方法步驟,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • 基于java中正則操作的方法總結(jié)

    基于java中正則操作的方法總結(jié)

    本篇文章介紹了,在java中正則操作的方法總結(jié)。需要的朋友參考下
    2013-05-05
  • mybatis框架xml下trim中的prefix與suffix等標簽的用法

    mybatis框架xml下trim中的prefix與suffix等標簽的用法

    這篇文章主要介紹了mybatis框架xml下trim中的prefix與suffix等標簽的用法,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-07-07
  • 一文搞懂如何實現(xiàn)Java,Spring動態(tài)啟停定時任務

    一文搞懂如何實現(xiàn)Java,Spring動態(tài)啟停定時任務

    定時任務的應用場景十分廣泛,如定時清理文件、定時生成報表、定時數(shù)據(jù)同步備份等。本文將教你實現(xiàn)Java、Spring動態(tài)啟停定時任務,感興趣的可以學習一下
    2022-06-06
  • 基于CopyOnWriteArrayList并發(fā)容器(實例講解)

    基于CopyOnWriteArrayList并發(fā)容器(實例講解)

    下面小編就為大家?guī)硪黄贑opyOnWriteArrayList并發(fā)容器(實例講解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-11-11
  • java虛擬機原理:類加載過程詳解

    java虛擬機原理:類加載過程詳解

    這篇文章主要介紹了Java中類加載過程全面解析,具有一定參考價值,需要的朋友可以了解下,希望能夠給你帶來幫助
    2021-09-09
  • springboot 監(jiān)控管理模塊搭建的方法

    springboot 監(jiān)控管理模塊搭建的方法

    本篇文章主要介紹了springboot 監(jiān)控管理模塊搭建的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03

最新評論