stuts2的賦值問題 1

jsjqjy發表於2009-07-23

1.POJO

 

 

public class UserBean {

	private String username;
	private String password;
              set/getUsername;
              set/getPassword;
}

 2. struts2 Action

 

public class UserInfor extends ActionSupport {

	private UserBean userBean = new UserBean();
                set/getUserBean;

}

 3.頁面 :

  

ognl 表示式取值 : ${userBean.username}   

name="userBean.username" 為了與後臺action中的userBean的username屬性進行繫結

 

UserName:<input type="text" value="${userBean.username}" name="userBean.username"  /><br>
      Password: <input type="text" value="${userBean.password}" name="userBean.password" /><br>

 

 

 

相關文章