访问struts2包括struts if struts中另一个jsp页面中的param值

Swa*_*ane 5 struts struts2

我在jsp页面中传递包含标签的param值,如下所示

    <s:include   value="../../commonjspf/status.jspf"> 
        <s:param name="mystatus" value="%{status}">
       </s:param>
    </s:include>
Run Code Online (Sandbox Code Playgroud)

其中status变量来自action类.

我想在struts中的status.jspf页面中访问mystatus param if tag以与我的默认值进行比较.

    <s:if test ="">
    </s:if>
Run Code Online (Sandbox Code Playgroud)

要么

  <s:set name="" value =""/>
Run Code Online (Sandbox Code Playgroud)

任何上述标签.

我怎么才能访问?

请建议我.

谢谢.

Jam*_*hin 8

使用${param.ParamName}符号访问它们,如下面的参考文献中所述:

http://struts.apache.org/2.0.14/docs/include.html

示例代码:

第1页:

        <s:include value="testPage.jsp">
            <s:param name="mystatus">TestThis</s:param>
        </s:include>
Run Code Online (Sandbox Code Playgroud)

第2页:

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="mystatus" value="${param.mystatus}" scope="page"/>
<s:if test='%{#attr.mystatus == "TestThis"}'>
    This is what we want
</s:if>
<s:else>
    This is not what we want
</s:else>
Run Code Online (Sandbox Code Playgroud)


Ume*_*thi 4

提供给包含页面的任何其他参数都无法通过标记在呈现的页面中访问,因为不会创建值堆栈。详细信息请参阅 Struts2 文档。

Struts2 包含标签

但是,您可以通过 HttpServletRequest 对象在 servlet 中访问它们,或者通过 scriptlet 从 JSP 页面访问它们。

${param.ParamName}
Run Code Online (Sandbox Code Playgroud)