在Struts 1.3中,将数据从动作传递到视图(jsp)的最佳实践是什么。?
我正在用struts 1.3编写web应用程序。我想将员工的ArrayList传递到JSP页面 我看到以下两种方法: 1. 将员工列表作为字段放入ActionForm在Struts 1.3中,将数据从动作传递到视图(jsp)的最佳实践是什么。?,jsp,jakarta-ee,web-applications,struts,struts-1,Jsp,Jakarta Ee,Web Applications,Struts,Struts 1,我正在用struts 1.3编写web应用程序。我想将员工的ArrayList传递到JSP页面 我看到以下两种方法: 1. 将员工列表作为字段放入ActionForm List<Employee> employees; 和JSP使用此数据作为: ${empForm.employees} 2. 直接将员工名单放入请求中 request.setAttribute("employees", employeeList); 将employeeList设置为请求的操作类 request.
List<Employee> employees;
和JSP使用此数据作为:
${empForm.employees}
2.
直接将员工名单放入请求中
request.setAttribute("employees", employeeList);
将employeeList设置为请求的操作类
request.setAttribute("employees", employeeList);
在JSP中:
${employees}
请建议我应该采用什么方法。在Struts 1.3中,哪一个被认为是良好的实践。两者都是正确的。如果页面需要表单,您可以将列表放在ActionForm中。就我个人而言,我更喜欢在ActionForm中设置,因为它更有条理。如果您需要编辑数据,最好将其放在ActionForm中,否则没有太大区别