2013-02-28 57 views
1

我有以下標籤:樣式屬性:文本返回錯誤

<html:text styleClass="span2" property="groupManagerId" styleId="groupManagerId" maxlength="19" size="10" readonly="" /> 

其正常工作。當我添加一個樣式屬性:

<html:text styleClass="span2" style="display:<%=(""+FVConstants.NORMAL).equalsIgnoreCase(groupData.getGroupType())?"none":" "%>;" property="groupManagerId" styleId="groupManagerId" maxlength="19" size="10" readonly="" /> 

我得到以下錯誤:

org.apache.jasper.JasperException: /pages/POS0085_group_modify.jsp(95,61) Unterminated &lt;html:text tag 

我有一個標籤和div標籤下相同的屬性和它工作正常。我改

<%String displayValue=(""+FVConstants.NORMAL).equalsIgnoreCase(groupData.getGroupType())?"none":" "; 
           String displayAttr="display:"+displayValue; %> 

<html:text styleClass="span2" style="display:<%=displayValue%>" property="groupManagerId" styleId="groupManagerId" maxlength="19" size="10" readonly="" /> 

和它的作品。第一次嘗試有什麼問題?有一個更好的方法嗎?

+0

上次我檢查,'<(%)=( 」「?+ FVConstants.NORMAL).equalsIgnoreCase(groupData.getGroupType())」 沒有括號包圍>'不是顯示樣式的有效css值。我想你可能會在你的文章中遺漏一些背景信息(也可能是標籤)。什麼過程的代碼? – 2013-02-28 14:39:22

+1

你不能像這樣嵌套scriptlets。更好的方法是設置一個可通過JSP EL訪問的值,併爲html-el標籤使用最近的容器。 – 2013-02-28 17:34:43

+0

@jdwire正確,但這不是錯誤所指示的 - 這是JSP標記問題,而不是CSS問題。 – 2013-02-28 17:36:18

回答

0

當初學者嘗試使用?運算符評估字符串時,經常會發生此錯誤。 「:」「%所評價的表達應與像

<html:text styleClass="span2" style="display:<%=((""+FVConstants.NORMAL).equalsIgnoreCase(groupData.getGroupType())?"none":" ")%>;" property="groupManagerId" styleId="groupManagerId" maxlength="19" size="10" readonly="" />