<bean:define>标记的各个属性的含义
2013-09-05 20:54
330 查看
<bean:define>标记的各个属性的含义
一是定义新字符串常量:<bean:define id="foo" value="This is a new String"/>
<bean:define id="bar" value='<%= "Hello, " + user.getName() %>'/>
<bean:define id="last" scope="session" value='<%= request.getRequestURI() %>'/>
二是复制一个现有的bean给新的bean:
<bean:define id="foo" name="bar"/>
<bean:define id="baz" name="bop" type="com.mycompany.MyClass"/> //定义脚本变量的类型,默认为Object
三是复制一个现有的bean的属性给新的bean:
<bean:define id="bop" name="user" property="role[3].name"/>
<bean:define id="foo" name="bar" property="baz" scope="request" toScope="session"/>
//toScope属性指新bean的scope,默认为page
上段代码的意思是把名为bar的bean的baz属性赋值给foo,foo的类型为String(默认)。
<bean:define id="pagename" name="requestName"/>
id:指的是这个bean的唯一名字,在此定义的网页里面可以随便的使用和访问/
name:指的是从上一个页面或者action里面传过来的变量,可以是任何类型。
例如:
我有一个User对象,这个里面保存了admin管理员的个人信息,有身份证号(idcode),性别(sex)、年龄(age)那么怎么用呢。
在action里面你可以把User对象传过来
request.setAttribute("user",User);
在页面
<bean:difine id="admin" name="user"./>
然后就可以和bean:write搭配使用
<bean:write name="admin" property="idcode"/>
<bean:write name="admin" property="sex"/>
<bean:write name="admin" property="age"/>
现在应该明白了吧。
相关文章推荐
- Beanを変数で定義する<bean:define>
- 使用<bean:define >取到bean:write的值,并赋值给java变量
- &lt;转&gt;Table中的几个特殊标记和属性
- Hibernate实体类映射文件demo.hbm.xml 中的<generator class="?"></generator>的不同属性含义
- <c:foreach> 标签 varStatus属性的含义
- <bean:write/>标签的format属性
- <label>标签for属性的妙用
- <input type="file" />accept属性列表
- <head>标记
- <a>标签 targe属性
- <input type="file" />accept属性列表
- <a>标签跳转和执行js函数,href和onclick属性
- &lt;html:link 各个属性解释及用法
- Spring配置中<bean>的id和name属性区分
- <转>SY-SUBRC 的含义
- <c:forEach varStatus="status">中 varStatus的属性简介
- <activity>元素的android:launchMod属性的使用
- <jsp:useBean>的使用
- Hibernate 的<generator class="native"></generator>的不同属性含义
- <div+css页面布局课堂笔记>4---与盒子相关的CSS属性