【发布时间】:2013-02-28 14:32:47
【问题描述】:
我有以下标签:
<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="" />
它有效。第一次尝试有什么问题?有没有更好的方法来做到这一点?
【问题讨论】:
-
我上次检查时,
<%=(""+FVConstants.NORMAL).equalsIgnoreCase(groupData.getGroupType())?"none":" "%>不是显示样式的有效 css 值。我认为您的帖子中可能缺少一些背景信息(可能还有标签)。什么处理该代码? -
你不能像这样嵌套 scriptlet。更好的方法是设置一个可通过 JSP EL 访问的值,并为 html-el 标签使用最近的容器。
-
@jdwire 正确,但这不是错误所指示的——这是 JSP 标记问题,而不是 CSS 问题。
-
@DaveNewton 我知道这是将在服务器端处理的其他语言,但问题没有提到除 html 之外的任何语言,如果语言是,OP 可能会得到更快的答案在问题和标签之一中说明。感谢您向其他人说明这一点。
标签: java jsp styles struts scriptlet