2012-06-21 36 views
1

我想顯示的鏈接,如果行的值等於「總計」其他純文本我想下面片斷,但得到的錯誤如果條件顯示標籤?

<display:table name="expScoreCardCol" export="true" pagesize="20" sort="list" id="data" requestURI="" class="tablelist"> 

    <display:column title="Zone" sortable="true" property="zone"></display:column>    
    <display:column title="Non-HNI Total" sortable="true" property="nonhniTotal"></display:column> 
     <display:column title="Non-HNI Per %" sortable="true" property="nonhniPer"></display:column> 

    <%if(!${data.zone}=="GRAND TOTAL"){ %>  
     <display:column title="Grand Total" sortable="true"> 
     <html:link action="/exceptionScoreCardGrandReport.do?zone=${data.zone}"><b>${data.grandTotal}</b></html:link> 
     </display:column> 
     <%} %> 
</display:table> 

錯誤:

An error occurred at line: 270 in the generated java file 
Syntax error, insert "while (Expression) ;" to complete DoStatement 

An error occurred at line: 282 in the generated java file 
Syntax error, insert "while (Expression) ;" to complete BlockStatements 

An error occurred at line: 288 in the generated java file 
Syntax error, insert "else Statement" to complete IfStatement 

An error occurred at line: 288 in the generated java file 
Syntax error, insert "}" to complete Block 
+0

有什麼錯誤? – Ankit

+0

編譯時錯誤。請參閱上面更新的文章 – happy

回答

4

不要使用小腳本。決不。使用JSTL和EL。並且要明白,EL不能在scriptlet中使用:腳本包含Java代碼,EL不是Java。

此外,如果特定行不是總計,代碼將添加一列。這不是應該做的。列應該永遠存在,但其內容應視該行更改:

<display:table name="expScoreCardCol" export="true" pagesize="20" sort="list" id="data" requestURI="" class="tablelist"> 
    <display:column title="Zone" sortable="true" property="zone" /> 
    <display:column title="Non-HNI Total" sortable="true" property="nonhniTotal" /> 
    <display:column title="Non-HNI Per %" sortable="true" property="nonhniPer" /> 
    <display:column title="Grand Total" sortable="true"> 
     <c:if test="${data.zone != 'GRAND TOTAL'}">  
      <html:link action="/exceptionScoreCardGrandReport.do?zone=${data.zone}"> 
       <b>${data.grandTotal}</b> 
      </html:link> 
     </c:if> 
    </display:column>  
</display:table>