简体   繁体   English

OptionTag类型的setValue(String)方法不适用于自变量(对象)

[英]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.

相关问题 声明类型中的方法assertEquals(Object,object)不适用于参数(String,Void) - Method assertEquals(Object, object) in the type Assert is not applicable for the arguments (String, Void) ArrayList类型中的方法add(String) <String> 不适用于参数(对象) - The method add(String) in the type ArrayList<String> is not applicable for the arguments (Object) 类型PrintStream的方法printf(String,Object ...)不适用于参数(String,void) - The method printf(String, Object…) in the type PrintStream is not applicable for the arguments (String, void) 字符串类型中的方法format(String,Object [])不适用于参数(…) - The method format(String, Object[]) in the type String is not applicable for the arguments (…) PrintStream 类型中的 printf(String, Object[]) 方法不适用于参数 (...) - The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (...) 类型object中的equals(object)方法不适用于参数 - the method equals(object) in the type object is not applicable to the arguments 部分类型中的方法setText(String)不适用于参数 - method setText(String) in the type Part is not applicable for the arguments 类型为nammi的方法epli(String [])不适用于arguments() - The method epli(String[]) in the type nammi is not applicable for the arguments () 类型“ x”的方法search()不适用于参数(字符串) - The method search() in the type “x” is not applicable for the arguments (String) 类型中的方法不适用于参数 - The method in the type is not applicable for the arguments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM