Parameter Passing for statically included page in Struts 2

前端 未结 1 619
隐瞒了意图╮
隐瞒了意图╮ 2021-01-16 00:30

I have a parent file where my JSP is statically included.

<%@include file=\"test.jsp\" %>

In the included file I want to access the v

相关标签:
1条回答
  • You can't access the variable but you can access the variable from the the value stack using OGNL. See OGNL Basics to learn more about variables in Struts and how to use them.

    Besides the examples and descriptions given above, there are a few major changes in the EL since WebWork 1.x. The biggest one is that properties are no longer accessed with a forward slash / but with a dot .. Also, rather than using .. to traverse down the stack, we now use [n] where n is some positive number. Lastly, in WebWork 1.x one could access special named objects (the request scope attributes to be exact) by using @foo, but now special variables are accessed using #foo. However, it is important to note that #foo does not access the request attributes. Because XWork is not built only for the web, there is no concept of "request attributes", and thus #foo is merely a request to another object in the OgnlContext other than the root.

    To include JSP content dynamically use s:include tag

    Include a servlet's output (result of servlet or a JSP page).

    Note: Any additional params supplied to the included page are not accessible within the rendered page through the <s:property...> tag since no valuestack will be created. You can, however, access them in a servlet via the HttpServletRequest object or from a JSP page via a scriptlet.

    How To access parameters

    Parameters are passed as request parameters, so use the ${param.ParamName} notation to access them. Do not use the property tag to access parameters in included files.

    <s:include value="test.jsp"/>
    
    0 讨论(0)
提交回复
热议问题