2012-08-29 27 views
0

从select属性中提取的值为null。从html中提取选定值:select

对JSP代码是..

<nested:select property="role.roleSID"> 
        <logic:iterate name="roleList" id="roleListId"> 
         <html:option 
          value="<bean:write name='roleListId' property='roleSID'/>"> 
          <bean:write name='roleListId' property='roleName' /> 
         </html:option> 
        </logic:iterate> 
       </nested:select> 

和行动类的代码是..

Long roleSID = userForm.getRole().getRoleSID(); 

列表框正确填充与预期值。但是在获取选定的值时,返回null。

你能告诉我哪里出了问题吗

回答

0

我试过另一种方式,给了我预期的结果。

的JSP内容是..

<html:select property="roleSID"> 
<html:options collection="roleList" property="roleSID" 
         labelProperty="roleName" /> 
</html:select> 

,动作内容是..

Long roleSID = userForm.getRoleSID(); 

而且用户窗体是表单bean其中包含与getter和setter roleSID属性。 roleList包含角色对象的集合,角色对象又包含roleName,roleSId属性。用户窗体也包含作为嵌套的角色bean。