【发布时间】:2013-01-31 02:47:15
【问题描述】:
我正在用 struts 1.3 编写 Web 应用程序。我想将员工的 ArrayList 传递给 JSP 页面。
我看到以下两种方法:
1. 将员工列表作为字段放入 ActionForm。
List<Employee> employees;
设置该字段的动作类:
empForm.setEmployees(employeeList);
而 JSP 使用这些数据作为:
${empForm.employees}
2. 将员工列表直接放入请求中。
Action 类将employeeList 设置为请求。
request.setAttribute("employees", employeeList);
在 JSP 中:
${employees}
请建议我应该采用哪种方法。 Struts 1.3 中哪一个被认为是好的实践。
【问题讨论】:
标签: jsp jakarta-ee web-applications struts struts-1