Pergunta

I'm having a problem with Struts. It's not recognizing a bean, even though it's defined one line above

I have this code

<logic:iterate id="com" name="Handler" property="commandList">
23:                             <optgroup id="${com.id}" style="display:none;">
24:                                 <logic:iterate id="rem" name="com" property="remotes">
25:                                     <option value="${rem.id}"><bean:write name="rem" property="name"/></option>
26:                                 </logic:iterate>
27:                             </optgroup>
28:                         </logic:iterate>

and I get the following error in line 25:

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean: "rem" in any scope

Which does not make sense, because the bean is defined just above on line 24

Any ideas? Thanks

Foi útil?

Solução

As you state, the syntax of your code is correct. My guess is that one of the remotes bean's object is a null value. In that case, according to struts1 reference :

If the collection you are iterating over can contain null values, the loop will still be performed but no page scope attribute (named by the id attribute) will be created for that loop iteration. You can use the <logic:present> and <logic:notPresent> tags to test for this case.

The <bean:write name="rem" property="name"/> tag will be executed, but rem won't exist in any scope. Check for null values in your Array/List/Map/etc remotes, or add a test using the <logic:present> tag.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top