如何使用< bean:write>标记在strut 1.2中? [英] how to use <bean:write > tag in strut 1.2?
问题描述
如何在Struts 1.2中使用<bean:write>
标记.
在name
属性中,必须使用什么值? Bean名称是您的财产名称吗?
用于 <bean:write>
:
指定要访问其属性的Bean的属性名称 检索由 property 指定的值(如果已指定).如果财产 未指定,则将呈现此bean本身的值.
本质上,如果您有JavaBean(带有getter和setter),
Person person = new Person;
request.setAttribute("person", person);
通过设置<bean:write name="person" property="age" />
,您告诉Struts首先从PageContext
范围中找到person
对象 first .如果找不到,则依次为request
,session
和application
范围.
property="age"
属性(来自<bean:write />
标记)将随后从Person
对象调用吸气剂方法getAge()
(与bean上是否存在名为age
的实例变量无关).>
希望这会有所帮助.
How to Use <bean:write>
tag in Struts 1.2.
In name
attribute, what value have to be used? Is bean name your property name?
Javadoc for <bean:write>
:
Specifies the attribute name of the bean whose property is accessed to retrieve the value specified by property (if specified). If property is not specified, the value of this bean itself will be rendered.
In essence, if you have a JavaBean (with getters and setters),
Person person = new Person;
request.setAttribute("person", person);
by setting <bean:write name="person" property="age" />
, you're telling Struts to first find person
object first from PageContext
scope. If not found, then request
, then session
, then application
scope.
The property="age"
attribute (from <bean:write />
tag), will then call the getter method getAge()
from the Person
object (irrespective of whether there's an instance variable called age
on the bean).
Hope this helps.
这篇关于如何使用< bean:write>标记在strut 1.2中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!