【问题标题】:How to display data in struts form if object has another object如果对象有另一个对象,如何以struts形式显示数据
【发布时间】:2023-03-10 18:27:01
【问题描述】:

我正在开发 struts 1.3 框架应用程序。 我在请求属性中设置了一个对象。

request.setAttribute("school",school);

我正在尝试通过<bean:define> 标签显示该对象。

例如 学校是价值对象

School school;

在学校 VO 对象我还有另外两个对象

Student student;
Teacher teacher;

我正在尝试显示学生和教师对象的价值

<bean:define id="summary" name="school" />
<bean:define id="StudentSummary" name="summary" property="student"/>
<bean:define id="TeacherSummary" name="summary" property="teacher"/>

并通过标签写入这个元素

<bean:write name="StudentSummary" property="name" />
<bean:write name="StudentSummary" property="class" />
<bean:write name="TeacherSummary" property="name" />

但它正在给予
javax.servlet.jsp.JspException:在 org.apache.struts.action.MESSAGE 键下找不到消息资源

代码有什么问题。

【问题讨论】:

    标签: struts struts-1


    【解决方案1】:

    我从来没有使用过 bean 标签,但你可以使用表达式语言(EL)来做到这一点。 EL,我相信这是一种更标准的做事方式。

    看看这个以前的帖子。我认为它有帮助Link

    我认为在你的情况下你可以做一些事情

    &lt;c:out value="${school.student.name}"/&gt;

    如果您的学生对象中有“name”属性,上述语句将打印“name”的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-18
      • 2019-04-14
      • 2014-08-28
      • 1970-01-01
      • 1970-01-01
      • 2019-09-30
      • 1970-01-01
      相关资源
      最近更新 更多