1

我正在研究 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: Cannot find message resources under key org.apache.struts.action.MESSAGE

代码有什么问题。

4

1 回答 1

2

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

看看这个以前的帖子。我认为它有助于链接

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

<c:out value="${school.student.name}"/>

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

于 2013-04-15T20:51:21.453 回答