[英]The method setValue(String) in the type OptionTag is not applicable for the arguments (Object)
I have the below code in my JSP. 我的JSP中包含以下代码。 The problem is while i run this code, i get the below exception:
问题是当我运行此代码时,出现以下异常:
The method setValue(String) in the type OptionTag is not applicable for the arguments (Object).
Does anyone have an idea? 有人有主意吗?
<html:select property="selectedServices" name="specificStoreForm" multiple="true" styleClass="services">
<logic:iterate id="service" name="services" property="selectedServices">
<bean:define id="textVal" name="service" property="value" toScope="request"/>
<html:option value="<%=textVal%>">
<bean:write name="service" property="label"/>
</html:option>
</logic:iterate>
</html:select>
Judging from the documentation the result from the <bean:define>
tag is of type Object
if you don't specify a value
attribute. 从文档中判断,如果您未指定
value
属性,则<bean:define>
标记的结果为Object
类型。 The <html:option>
tag only works if the passed value is of type String
. <html:option>
标记仅在传递的值为String
类型时才有效。
Use EL (Expression Language) to get the value instead: 使用EL(表达语言)来获取值:
<html:option value="${textVal}">
...
</html>
You could also just use the <html:optionsCollection>
tag and not have to explicitly iterate: 您也可以只使用
<html:optionsCollection>
标记,而不必显式迭代:
<html:select property="selectedServices" name="specificStoreForm" multiple="true" styleClass="services">
<html:optionsCollection name="services" property="selectedServices" value="value" label="label"/>
</html:select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.