当前位置: 技术问答>java相关
请问useBean的scope属性设置成page和设置成request有什么区别?详细点!
来源: 互联网 发布时间:2015-07-24
本文导语: 详细点!!! | page This is the default value. It indicates that, in addition to being bound to a local variable, the bean object should be placed in the PageContext object for the duration of the current reques...
详细点!!!
|
page
This is the default value. It indicates that, in addition to being
bound to a local variable, the bean object should be placed in the
PageContext object for the duration of the current request. In
principle, storing the object there means that servlet code can
access it by calling getAttribute on the predefined
pageContext variable. In practice, beans created with page
scope are almost always accessed by jsp:getProperty,
jsp:setProperty, scriptlets, or expressions later in the same
page.
request
This value signifies that, in addition to being bound to a local
variable, the bean object should be placed in the
ServletRequest object for the duration of the current request,
where it is available by means of the getAttribute method.
This value is only a slight variation of the per-request scope
provided by scope="page" (or by default when no scope is
specified).
This is the default value. It indicates that, in addition to being
bound to a local variable, the bean object should be placed in the
PageContext object for the duration of the current request. In
principle, storing the object there means that servlet code can
access it by calling getAttribute on the predefined
pageContext variable. In practice, beans created with page
scope are almost always accessed by jsp:getProperty,
jsp:setProperty, scriptlets, or expressions later in the same
page.
request
This value signifies that, in addition to being bound to a local
variable, the bean object should be placed in the
ServletRequest object for the duration of the current request,
where it is available by means of the getAttribute method.
This value is only a slight variation of the per-request scope
provided by scope="page" (or by default when no scope is
specified).
|
request scope和page scope的范围是不一样的!
一个request可能会跨越多个page执行。
一个request可能会跨越多个page执行。
|
书上说request scope也称为page scope,只存在于clent与server间的一次边线(request/response之间),即request scope和page scope的作用范围一样。