jsp:setProperty getProperty标签的应用
添加时间:2013-6-11 点击量:
1、Person.java 该JavaBean 用户封装信息
import java.util.Date;
public class Person {
private String name = aaa;
private String password;
private int age;
private Date birthday;
private Address address;
public void setBirthday(Date birthday){
this.birthday = birthday;
}
public Date getBirthday(){
return birthday;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
return age;
}
public void setName(String name){
this.name= name;
}
public String getName(){
return name;
}
public void setPassword(String password){
this.password= password;
}
public String getPassword(){
return password;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
}
2,jsp:setProperty getProperty标签的应用
<%@ page language=java import=java.util. pageEncoding=UTF-8%>
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>
<html>
<head>
<title>jsp:setProperty getProperty标签的应用</title>
</head>
<body>
<!-- jsp:setProperty标签在工作时,它会主动把字符串转成八种根蒂根基数据类型 -->
<!-- 然则jsp:setProperty标签对于错杂类型无法主动进行转换 -->
<jsp:useBean id=person class=cn.itcast.Person scope=page/>
<jsp:setProperty name=person property=name value=qqqq/>
<jsp:setProperty name=person property=password value=123/>
<jsp:setProperty name=person property=age value=12/>
<jsp:setProperty name=person property=birthday value=<%=new Date() %>/>
<!-- jsp:setProperty标签可以应用恳求参数为bean的属性赋值 -->
<jsp:setProperty name=person property=name param=name/>
<!-- jsp:setProperty标签用所有的恳求参数为bean的属性赋值 -->
<!-- http://localhost:8080/day09/2.jsp?name=flx&password=123&age=34 -->
<jsp:setProperty name=person property=/>
<%
System.out.println(person.getName());
System.out.println(person.getPassword());
System.out.println(person.getAge());
%>
<jsp:getProperty name=person property=name/>
</body>
</html>
1、Person.java 该JavaBean 用户封装信息
import java.util.Date;
public class Person {
private String name = aaa;
private String password;
private int age;
private Date birthday;
private Address address;
public void setBirthday(Date birthday){
this.birthday = birthday;
}
public Date getBirthday(){
return birthday;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
return age;
}
public void setName(String name){
this.name= name;
}
public String getName(){
return name;
}
public void setPassword(String password){
this.password= password;
}
public String getPassword(){
return password;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
}
2,jsp:setProperty getProperty标签的应用
<%@ page language=java import=java.util. pageEncoding=UTF-8%>
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>
<html>
<head>
<title>jsp:setProperty getProperty标签的应用</title>
</head>
<body>
<!-- jsp:setProperty标签在工作时,它会主动把字符串转成八种根蒂根基数据类型 -->
<!-- 然则jsp:setProperty标签对于错杂类型无法主动进行转换 -->
<jsp:useBean id=person class=cn.itcast.Person scope=page/>
<jsp:setProperty name=person property=name value=qqqq/>
<jsp:setProperty name=person property=password value=123/>
<jsp:setProperty name=person property=age value=12/>
<jsp:setProperty name=person property=birthday value=<%=new Date() %>/>
<!-- jsp:setProperty标签可以应用恳求参数为bean的属性赋值 -->
<jsp:setProperty name=person property=name param=name/>
<!-- jsp:setProperty标签用所有的恳求参数为bean的属性赋值 -->
<!-- http://localhost:8080/day09/2.jsp?name=flx&password=123&age=34 -->
<jsp:setProperty name=person property=/>
<%
System.out.println(person.getName());
System.out.println(person.getPassword());
System.out.println(person.getAge());
%>
<jsp:getProperty name=person property=name/>
</body>
</html>