一、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) |