我有一个UserBean类,有属性userName并有相应的get,set方法。
在用户登陆时,我把用户信息封装在UserBean对象中。
那么在页面中用<html:select>和<html:options>标签,如何写?
List<UserBean> onLineList =
request.setAttribute("onLineList ")
在用户登陆时,我把用户信息封装在UserBean对象中。
那么在页面中用<html:select>和<html:options>标签,如何写?
List<UserBean> onLineList =
request.setAttribute("onLineList ")
<s:select list="onLineList" listValue="name" listKey="id" name="onLineId" theme="simple"></s:select>
写法应该都差不多
<html:options collection="onLineList" property="userName" labelProperty="userName"/>
</html:select>
* 用于封装session中用户信息
* @author Administrator
*/
public class UserBean
{
private String userName; public UserBean(String userName)
{
this.userName = userName;
}
public UserBean(){} public String getUserName() {
return userName;
} public void setUserName(String userName) {
this.userName = userName;
}
}form:
package com.ysj.struts.form;import org.apache.struts.action.ActionForm;public class LoginForm extends ActionForm
{
private String userName; public String getUserName() {
return userName;
} public void setUserName(String userName) {
this.userName = userName;
}}action:
List <UserBean> onLineList =
request.setAttribute("onLineList ") 页面:
<html:select property="userName">
<html:options collection="onLineList" property="userName" labelProperty="userName"/>
</html:select>