WEB-INF-----classes---Ball.java----com(Ball.class)
ball.java
package com;
public class Ball{
private String color;
private float price;
private float weight;
private String factory;/*制造商*/
public void setColor(String c){
this.color=c;
}
public String getColor(){
return this.color;
}
public void setPrice(float p){
this.price = p;
}
public float getPrice(){
return this.price;
}
public void setWeight(float w){
this.weight=w;
}
public float getWeight(){
return this.weight;
}
public void setFactory(String f){
this.factory=f;
}
public String getFactory(){
return this.factory;
}
}
ball1.jsp
<%@ page contentType="text/html;Charset=gbk"%>
<html>
<body>
<center>
<font size="20">
<jsp:useBean id= "ball" class="com.Ball" scope= "session"/>
<%ball.setColor("藍色");%>
<jsp:setProperty name="ball" property= "price"
value= "528" />
<jsp:setProperty name="ball" property= "weight"
value= "1.02" />
<jsp:setProperty name="ball" property= "factory"
value= "美國" />
籃球的顏色為:
<jsp:getProperty name= "ball" property= "color" /><br>
價格為:
<jsp:getProperty name= "ball" property= "price" /><br>
重量為:
<jsp:getProperty name= "ball" property= "weight" /><br>
產地為:
<jsp:getProperty name= "ball" property= "factory" /><br>
<a href="ball2.jsp">點我看看</a>
</font>
</body>
</html>
ball2.jsp
<%@ page contentType="text/html;Charset=gbk"%>
<html>
<body>
<center>
<font size="20">
<jsp:useBean id= "ball" class="com.Ball" scope= "session"/>
籃球的顏色為:
<%=ball.getColor()%><br>
價格為:
<jsp:getProperty name= "ball" property= "price" /><br>
重量為:
<jsp:getProperty name= "ball" property= "weight" /><br>
產地為:
<jsp:getProperty name= "ball" property= "factory" /><br>
<a href="ball3.jsp">再點我看看</a>
</font>
</body>
</html>
ball3.jsp
<%@ page contentType="text/html;Charset=gbk"%>
<html>
<body>
<center>
<font size="20">
<jsp:useBean id= "ball" class="com.Ball" scope= "session"/>
籃球的顏色為:
<jsp:getProperty name= "ball" property= "color" /><br>
價格為:
<jsp:getProperty name= "ball" property= "price" /><br>
重量為:
<jsp:getProperty name= "ball" property= "weight" /><br>
產地為:
<jsp:getProperty name= "ball" property= "factory" /><br>
這是ball3.jsp的頁面
<a href="ball4.jsp">換種方法看一下</a>
</font>
</body>
</html>
ball4.jsp
<%@ page contentType="text/html;Charset=gbk"%>
<html>
<body>
<center>
<font size="20">
<jsp:useBean id= "ball" class="com.Ball" scope= "session"/>
籃球的顏色為:
<%=ball.getColor()%>
<br>
價格為:
<%=ball.getPrice()%><br>
重量為:
<%=ball.getWeight()%><br>
產地為:
<%=ball.getFactory()%><br>
這是ball4.jsp的頁面
</font>
</body>
</html>
posted on 2009-05-05 21:04
鵬凌 閱讀(146)
評論(0) 編輯 收藏 所屬分類:
Java --j2ee