2016-01-22 25 views
0

我曾經的代碼在JSP文件中的以下線在我的網站的三重錯誤TLD使用

<% if (!maintenance) { %> 
<customTag:DialogEntry entry="<%=new com.presentation.generic.session.DialogEntry("dialog1","225px","true","true",new String[]{"authentification.Login.action.logInApplicationLabel"},new String[]{"logInApplication()"}) %>"/> 
<% } else { %> 
<customTag:DialogEntry entry="<%=new com.presentation.generic.session.DialogEntry("dialog1","225px","true","true",new String[]{},new String[]{}) %>"/> 
<% } %> 

,我得到的錯誤信息是:

/WEB- INF /標籤/ DialogEntry.tag按照TLD,價值 屬性不接受任何表情

我該如何解決這個問題呢?

DialogEntry.tag:

<%@ attribute name="entry" rtexprvalue="true" type="com.presentation.generic.session.DialogEntry" %> 

<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %> 
<%@ taglib uri="http://struts.apache.org/tags-html-el" prefix="html" %> 
<%@ taglib uri="http://struts.apache.org/tags-bean-el" prefix="bean" %> 
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> 
<%@ taglib uri="http://struts.apache.org/tags-logic-el" prefix="logic" %> 




    <script type="text/javascript"> 

    //confirm("<c:out value="${entry.id}" /> début"); 

    var <c:out value="${entry.id}" /> = new YAHOO.widget.Dialog("<c:out value="${entry.id}" />", 
      { 
     width: "<c:out value="${entry.size}" />", 
     <c:if test="${\"\" != entry.visible}"> 
      visible:true, 
     </c:if> 
     <c:if test="${\"\" == entry.visible}"> 
      visible:false, 
     </c:if> 


     close:false, 
     draggable :false 
     <c:if test="${\"\" != entry.effect}"> 
      ,effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.5} 
         }); 
     </c:if> 
     <c:if test="${\"\" == entry.effect}"> 
      }); 
     </c:if> 

     <c:if test="${\"false\" != entry.hasButtons}"> 

      var myButtons = [ 
      <c:forEach var="button" items="${entry.buttons}" varStatus="ind"> 
        { text:"<bean:message key="${button}"/>", handler:function() {<c:out value="${entry.functions[ind.index]}" />;}, isDefault:true } 
        <c:if test="${!empty entry.buttons[ind.index+1]}"> 
         , 
        </c:if> 
      </c:forEach> 
      ]; 

      <c:out value="${entry.id}" />.cfg.queueProperty("buttons", myButtons); 
     </c:if> 

    // confirm("<c:out value="${entry.id}" /> fin - debut script"); 

    if($.browser.msie && $('#header').size() > 0){ 

     // confirm("<c:out value="${entry.id}" /> fin - debut script IE"); 
     var menuWidth = $("div#menu").get(0).clientWidth; 

     var headerHeight = $("div#header").get(0).clientHeight; 

     var width = document.body.clientWidth; 
     var contentWidthConnected = width - menuWidth; 

     if($('div#content_onglets').size() > 0){ 
      // confirm("<c:out value="${entry.id}" /> fin - debut script IE Onglet"); 
      <c:out value="${entry.id}" />.cfg.queueProperty("x", 50); 
      <c:out value="${entry.id}" />.cfg.queueProperty("y", 0); 

     } 
     else{ 
      // confirm("<c:out value="${entry.id}" /> fin - debut script IE Pas Onglet"); 
      <c:out value="${entry.id}" />.cfg.queueProperty("x", menuWidth + 50); 
      <c:out value="${entry.id}" />.cfg.queueProperty("y", headerHeight); 
     } 

     // confirm("<c:out value="${entry.id}" /> fin - FIN script IE"); 

    } 
    else{ 
     <c:out value="${entry.id}" />.cfg.queueProperty("fixedcenter", true); 
    }  

    // confirm("<c:out value="${entry.id}" /> fin script"); 

    <c:out value="${entry.id}" />.render(); 



    // confirm("<c:out value="${entry.id}" /> fin script 2"); 
    </script> 
+0

@Satya對不起,我不明白 – Mercer

+1

而不是使用雙引號嘗試單引號。 – Satya

+0

你完全改變了這個問題。你應該已經接受了解決你問題的答案之一,併爲你的新問題開了一個新答案。 –

回答

2

要麼逃避自己內心的報價:

<% if (!maintenance) { %> 
    <customTag:DialogEntry entry="<%=new com.presentation.generic.session.DialogEntry(\"dialog1\",\"225px\",\"true\",\"true\",new String[]{\"authentification.Login.action.logInApplicationLabel\"},new String[]{\"logInApplication()\"}) %>"/> 
<% } else { %> 
    <customTag:DialogEntry entry="<%=new com.presentation.generic.session.DialogEntry(\"dialog1\",\"225px\",\"true\",\"true\",new String[]{},new String[]{}) %>"/> 
<% } %> 

或者使用單引號:

<% if (!maintenance) { %> 
    <customTag:DialogEntry entry='<%=new com.presentation.generic.session.DialogEntry("dialog1","225px","true","true",new String[]{"authentification.Login.action.logInApplicationLabel"},new String[]{"logInApplication()"}) %>'/> 
<% } else { %> 
    <customTag:DialogEntry entry='<%=new com.presentation.generic.session.DialogEntry("dialog1","225px","true","true",new String[]{},new String[]{}) %>'/> 
<% } %> 

閱讀錯誤消息is quoted with " which must be escaped when used within the value您會發現在文本中有"是原因。因此,要麼您的文本沒有用"(第二種解決方案,其中您使用')或文本內的"定義爲\以將它們轉義並使其成爲文本中的實際字符。

+0

當我做你的解決方案我有這個消息 '/WEB-INF/tags/DialogEntry.tag根據頂級域名,價值屬性不接受任何表達式。' – Mercer

+1

這是你的代碼中的其他問題,我不知道。也許開個新問題或編輯這個問題? – BlueMoon93

+0

我添加了我的'DialogEntry.tag'源文件 – Mercer

1

逃避所有 「與\」 你的塊中:

entry="" 
+0

根據這個例外,你錯過了一些報價。 – eg04lt3r