JSP JavaBean的setProperty屬性
更新時(shí)間:2009年10月04日 15:42:40 作者:
JSP JavaBean的setProperty屬性使用實(shí)例。
1.包:
package PaintBrush;
/**
*
* @author lucifer
*/
public class PaintBrush {
private String curcolor = "red";
public String getColor(){
return curcolor;
}
public void setColor(String color){
curcolor = color;
}
}
2.JSP代碼:
<%--
Document : TestSetPro
Created on : 2009-10-3, 15:02:50
Author : lucifer
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="brush" class="PaintBrush.PaintBrush"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
Original Color:
<jsp:getProperty name="brush" property="color"/>
<br>
Changed Color:
<jsp:setProperty name="brush" property="color" value="blue"/>
<jsp:getProperty name="brush" property="color"/>
</body>
</html>
3.輸出:
Original Color: red
Changed Color: blue
復(fù)制代碼 代碼如下:
package PaintBrush;
/**
*
* @author lucifer
*/
public class PaintBrush {
private String curcolor = "red";
public String getColor(){
return curcolor;
}
public void setColor(String color){
curcolor = color;
}
}
2.JSP代碼:
復(fù)制代碼 代碼如下:
<%--
Document : TestSetPro
Created on : 2009-10-3, 15:02:50
Author : lucifer
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="brush" class="PaintBrush.PaintBrush"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
Original Color:
<jsp:getProperty name="brush" property="color"/>
<br>
Changed Color:
<jsp:setProperty name="brush" property="color" value="blue"/>
<jsp:getProperty name="brush" property="color"/>
</body>
</html>
3.輸出:
Original Color: red
Changed Color: blue
相關(guān)文章
基于jsp+mysql實(shí)現(xiàn)在線水果銷售商城系統(tǒng)
這篇文章主要介紹了全新基于jsp+mysql實(shí)現(xiàn)的一個(gè)在線水果銷售商城系統(tǒng),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-08-08JDBCTM 指南:入門6-PreparedStatement
JDBCTM 指南:入門6-PreparedStatement...2006-10-10response.getWriter().write()向前臺(tái)打印信息亂碼問題解決
本節(jié)主要介紹了response.getWriter().write()向前臺(tái)打印信息亂碼問題解決方法,需要的朋友可以參考下2014-08-08jsp實(shí)現(xiàn)簡(jiǎn)單圖片驗(yàn)證碼功能
這篇文章主要為大家詳細(xì)介紹了jsp實(shí)現(xiàn)簡(jiǎn)單圖片驗(yàn)證碼功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-02-02JSP實(shí)現(xiàn)的簡(jiǎn)單分頁(yè)示例
這篇文章主要介紹了JSP實(shí)現(xiàn)的簡(jiǎn)單分頁(yè),涉及jsp簡(jiǎn)單數(shù)據(jù)庫(kù)查找及遍歷實(shí)現(xiàn)分頁(yè)的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10JSP 開發(fā)之Struts2內(nèi)建自定義攔截器
這篇文章主要介紹了JSP 開發(fā)之Struts2內(nèi)建自定義攔截器的相關(guān)資料,需要的朋友可以參考下2017-04-04jsp中如何實(shí)現(xiàn)按下回車鍵自動(dòng)提交表單
當(dāng)提交form表單數(shù)據(jù)時(shí)直接觸發(fā)回車鍵,就可以提交表單。為了省事很多時(shí)候希望可以按回車鍵來提交表單,要控制這些行為,可以借助JS來達(dá)到要求。2016-10-10