2012-08-29 29 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。