Java 如何在 struts 1.x 中的 JSP 中获取表单 bean 值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22951780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 19:34:12  来源:igfitidea点击:

How to get form bean value in JSP in struts 1.x

javajspstruts-1

提问by Rookie007

I need to get form bean value in jsp in struts 1.x

我需要在 struts 1.x 中的 jsp 中获取表单 bean 值

I am trying following code but that doesn't help.

我正在尝试以下代码,但这无济于事。

<c:forEach begin="1" end='here I need that from bean value' var="i"  >
    <c:choose>
        <c:when test="${param.pageNumberInput eq i}">
            <td>
                <c:out value="${i}" />
            </td>
        </c:when>
        <c:otherwise>
            <td>
                <a href="#"><c:out value="${i}" /> </a>
            </td>
        </c:otherwise>
    </c:choose>
</c:forEach>

I can get form bean value using the following tag

我可以使用以下标签获取表单 bean 值

But when I try like this it doesn't work

但是当我这样尝试时它不起作用

<c:forEach begin="1" end='<bean:write name="formBeanName" property="propertyName" />'   var="i"  >
    <c:choose>
        <c:when test="${param.pageNumberInput eq i}">
            <td>
                <c:out value="${i}" />
            </td>
        </c:when>
        <c:otherwise>
            <td>
                <a href="#"><c:out value="${i}" /></a>
            </td>
        </c:otherwise>
    </c:choose>
</c:forEach>

Please help how to get this formBeanproperty value.

请帮助如何获取此formBean属性值。

采纳答案by JB Nizet

end='${formBeanBame.propertyName}'

You can't use a JSP tag in an attribute of another JSP tag. And The JSP EL is all you need to access properties of beans.

不能在另一个 JSP 标记的属性中使用 JSP 标记。并且 JSP EL 是您访问 bean 属性所需的全部内容。