这是一种设置JavaBean对象实例中成员属性值的快捷操作方式。使用该方式,在JavaBean对象实例中的成员属性名称、数据类型等都必须和请求request对象中的参数名称和数据类型保持匹配。因此,采用property=“*”方式操作访问Java组件对象实例中的成员属性适用于JavaBean对象实例中的成员属性名与request对象中的参数名称一致的情况。
例如:
提交的表单:
<form method="post" action="showUserRegister.jsp">
用户名:<input name="userName" type="text"></br>
用户密码:<input name="userPassword" type="password"></br>
确认密码:<input name="userVerPassword" type="password"></br>
身份证号:<input name="userID" type="text"></br>
<input type="submit" value="注册完成">
<input type="reset" value="重新注册">
</form>
JavaBean:
public class user {
private String userName = null;
private String userPassword = null;
private String userVerPassword = null;
private String userID = null;
public user() {
super();
}
public user(String userName, String userPassword, String userVerPassword,
String userID) {
super();
this.userName = userName;
this.userPassword = userPassword;
this.userVerPassword = userVerPassword;
this.userID = userID;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
public String getUserVerPassword() {
return userVerPassword;
}
public void setUserVerPassword(String userVerPassword) {
this.userVerPassword = userVerPassword;
}
public String getUserID() {
return userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
public boolean isTheSame(){
if((this.userPassword).equals(this.userVerPassword))
return true;
else
return false;
}
}
动作标签的快捷访问方式:
<jsp:useBean id="user" class="JavaBean.user" scope="request"></jsp:useBean>
<jsp:setProperty property="*" name="user"/>
这样就将表单提交的信息都存到JavaBean里