惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
P
Palo Alto Networks Blog
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
S
Schneier on Security
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
雷峰网
雷峰网
T
Tenable Blog
人人都是产品经理
人人都是产品经理
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Scott Helme
Scott Helme
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Recorded Future
Recorded Future
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
Cloudbric
Cloudbric
C
Check Point Blog
Engineering at Meta
Engineering at Meta
TaoSecurity Blog
TaoSecurity Blog
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
腾讯CDC
量子位
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
Kaspersky official blog
Vercel News
Vercel News
F
Full Disclosure
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs

博客园 - 千年寒冰

C# 操作Excel大全 Wince 或Windows平台 C#调用Bitmap对象后资源应该如何释放 Window7+vs2008+QT环境搭建 基于三汇语音卡的呼叫中心开发--(一) 解决NTLDR is missing,系统无法启动的方法 mssql charindex 美化表单 屏幕取字原理 jsp web项目开发详述 jsp request 对象详解 博文阅读密码验证 - 博客园 WML教程9:Select List 控件 jsp的session介绍 (转) 想一想 javabean :类与函数调用(数据库访问类) JSP中的pageEncoding和contentType属性(转) javabean在jsp中的调用(原创) 远程连接SQL Server (转) 三天学好ADO(转)
jsp调用javabean实例
千年寒冰 · 2007-08-31 · via 博客园 - 千年寒冰

jsp调用javabean实例 goodsbean.java

package sale;
public class goodsbean{
    String Product;
    double Price;
    public goodsbean (){
    this.Product = "box";
    this.Price = 5.0;
    }
public void setProduct (String ProductName){
    this.Product = ProductName;
}
public String getProduct(){
    return (this.Product);
}
public void setPrice (double priceValue){
    this.Price = priceValue;
}
public double getPrice(){
    return (this.Price);
}
}

编译完生成的.class文件,放到:Tomcat 5.5\webapps\ROOT\WEB-INF\classes\sale 目录下。

调用方法:

<%@ page contentType="text/html;charset=GB2312"%>
<%//request.setCharacterEncoding("iso_8859_1");%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>goodsbean</title>
</head>

<body>

<jsp:useBean id="goodsbean" scope="application" class="sale.goodsbean" />
<%
goodsbean.setProduct("clock");
goodsbean.setPrice(17);
%>
使用方法1:
产品:<%= goodsbean.getProduct()%><br>
税率:<%= goodsbean.getPrice()%>

<%goodsbean.setProduct("chair");
goodsbean.setPrice(3);
%>
<br>使用方法2:
产品:<jsp:getProperty name="goodsbean" property = "Product" />
<br>
税率:<jsp:getProperty name="goodsbean" property = "Price" />

</body>
</html>

注意:设置bean的属性如下

<jsp:setProperty name="goodsbean" property = "Product"   value="asdf"/>
<jsp:setProperty name="goodsbean" property = "Price" value="adad" />

posted @ 2007-08-31 16:35  千年寒冰  阅读(9448)  评论()    收藏  举报