gpt4 book ai didi

java - OptionTag 类型中的 setValue(String) 方法不适用于参数 (Object)

转载 作者:行者123 更新时间:2023-12-01 13:18:31 25 4
gpt4 key购买 nike

我的 JSP 中有以下代码。问题是当我运行此代码时,出现以下异常:

The method setValue(String) in the type OptionTag is not applicable for the arguments (Object).  

有人有想法吗?

<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>

最佳答案

documentation来看<bean:define> 的结果标签的类型为Object如果您不指定 value属性。 <html:option>仅当传递的值的类型为 String 时,标记才有效.

使用 EL(表达式语言)来获取值:

<html:option value="${textVal}">
...
</html>

您也可以只使用 <html:optionsCollection> 标记并且不必显式迭代:

<html:select property="selectedServices" name="specificStoreForm" multiple="true" styleClass="services">
<html:optionsCollection name="services" property="selectedServices" value="value" label="label"/>
</html:select>

关于java - OptionTag 类型中的 setValue(String) 方法不适用于参数 (Object),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22251798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com