代码之家  ›  专栏  ›  技术社区  ›  bakoyaro CoreyRDean

如何使用struts 1上的JSTL检索请求范围的变量

  •  0
  • bakoyaro CoreyRDean  · 技术社区  · 14 年前

    我正在重构一些使用struts 1的遗留代码(请不要使用flames),并且检索我在Action类中设置的参数时遇到了困难。下面是我在JSP中使用的代码:

    我在action类中设置了变量 submissionfailure

    <c:out value=“$requestScope[cardolderzipcode]”/>

    <c:out value=“$requestScope.property[submissionfailure]”/>

    然而,没有任何输出。

    我将以下代码放入JSP中,可以在RequestScope映射中看到该值:

    <b><i>请求范围</i></b><br/> <c:foreach items=“$requestScope”var status=“status”var=“parameter”> <C:out value=“$参数”/><br/><br/>
    </C:foreach>

    但我还是不能把变量取出来。有人能帮我吗?或者我只是在享受I-D-10-T时刻?在动作课上,但是当我试着

    <c:out value="${requestScope[cardHolderZipCode]}" />

    <c:out value="${requestScope.property[submissionFailure]}" />

    然而,没有任何输出。

    我在JSP中放入了以下代码,我可以在RequestScope映射中看到该值:

    <b><i>请求范围lt;/i></b><br/> <c:foreach items=“$requestScope”var status=“status”var=“parameter”> <C:out value=“$参数”/>gt;<br/>gt;<br/>;
    </C:foreach>

    但我还是不能把变量取出来。有人能帮我吗?或者我只是在享受I-D-10-T时刻?

    2 回复  |  直到 14 年前
        1
  •  1
  •   Gary    14 年前

    From the Struts1 reference

    private {type} fieldName;
    
    public {type} getFieldName() {
      return (this.fieldName);
    }
    public void setFieldName({type} fieldName) {
      this.fieldName = fieldName;
    }
    

        2
  •  1
  •   bakoyaro CoreyRDean    14 年前

    <c:choose>
        <c:when test="${submissionFailure}">
             <%-- Do something --%>
        </c:when>
        <c:otherwise>
             <%-- Do something else --%>
        </c:otherwise>
    </c:choose>