1

我尝试对 onChange 事件使用 2 个不同的函数,如下所示:

<html:select  property="distributionCategoryCode" tabindex="5"   onchange="<c:choose><c:when test="${model.editT == true}">enableTextboxDirect('${model.dtxtrmks}');</c:when><c:otherwise>enableTextboxDirect();</c:otherwise></c:choose>" >

但是得到如下JSP错误:

期望引用值,得到字符:= 属性:${model.editTaxes 不是有效的属性名称期望引用值,得到字符:t

有什么输入吗?

4

1 回答 1

2

You can't arbitrarily nest JSP tags like that, it's not legal JSP (or XML).

You need to set the value separately.

In this case I barely see a reason to special-case it in the rendered output, instead pass two parameters to enableTextboxDirect. I don't see a usecase for doing it any other way.

<html:select property="distributionCategoryCode"
             onchange="enableTextboxDirect(${model.editT}, '${model.dtxtrmks}')>

Even if you had to write a one-liner JS wrapper in case you cannot modify enableTextboxDirect it's still a better solution than bothering to change the entire attribute.

于 2013-06-19T19:39:54.607 回答