Chinaunix首页 | 论坛 | 博客
  • 博客访问: 535611
  • 博文数量: 151
  • 博客积分: 7010
  • 博客等级: 少将
  • 技术积分: 1405
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-22 14:32
文章分类

全部博文(151)

文章存档

2011年(1)

2010年(23)

2009年(1)

2008年(126)

我的朋友

分类: 系统运维

2008-08-11 11:14:56

一、Passing Control from One Page to Another
The pages can pass control through the action,for example  

The action stops processing of one page and starts processing the page specified by the attribute instead,called the target page.The target page has access to all information about the request,including all request parameters.You can also add additional request parameters when you pass control to another page by using one or more nested  action elements.
   
      
      
   
 

Parameters specified with elements are added to the parameters received with the original request.the target page, therefore,has access to both the original parameters and the new ones.If a parameter is added to the request using a name of a parameter that already exists,the new value is added first in the list of values for the parameter.

二、Passing Data from One Page to Another
JSP provides different scopes for sharing data objects between pages,request,and users.The flowing scopes are defined:pages,request,session,and application.
The has a 'scope' attribute used to specify the scope for the bean:
  

The action ensures that the bean already exists in the scope or that a new one is created and placed in the specified scope.

If you'd like to perform an action only when the bean is created,place the elements in the body of the action:
   
     
   

In this example,the nested action sets all properties to the values of the corresponding parameters when the bean is created.If the bean already exists, the action body isn't evaluated.and the action isn't executed.

You can access a bean created by the action as a variable in EL expressions.Typically you just specified the variable name no matter which scope it's saved ,for instance:
    ${userInfo.userName}
In this case,the EL looks for the variable in all scopes in the order page,request,session,application.If it's important to locate a variable in a specified scope,you can use the implicit EL variable represending the different scopes:
    ${pageScope.userInfo.userName}
    ${requestScope.userInfo.userName}
    ${sessionScope.userInfo.userName}
    ${applicationScope.userInfo.userName}
Each scope variable represents a collection(a java.util.Map) of all variables in that scope,so with expression like these,the EL looks for the variable only in the specified scope.
 
阅读(764) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~