我有以下标签:
<html:text styleClass="span2" property="groupManagerId" styleId="groupManagerId" maxlength="19" size="10" readonly="" />
它工作正常。当我添加 style
属性时:
<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 <html:text tag
我在 label
和 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="" />
并且它有效。第一次尝试有什么问题?有更好的方法吗?
最佳答案
当初学者尝试使用 ?
运算符计算字符串时,经常会发生此错误。计算的表达式应该像这样用括号括起来
<html:text styleClass="span2" style="display:<%=((""+FVConstants.NORMAL).equalsIgnoreCase(groupData.getGroupType())?"none":" ")%>;" property="groupManagerId" styleId="groupManagerId" maxlength="19" size="10" readonly="" />
关于java - html 内的样式属性 :text expression error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15138077/