Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Struts 1.3中,将数据从动作传递到视图(jsp)的最佳实践是什么。?_Jsp_Jakarta Ee_Web Applications_Struts_Struts 1 - Fatal编程技术网

在Struts 1.3中,将数据从动作传递到视图(jsp)的最佳实践是什么。?

在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.

我正在用struts 1.3编写web应用程序。我想将员工的ArrayList传递到JSP页面

我看到以下两种方法:

1. 将员工列表作为字段放入ActionForm

List<Employee>  employees;
和JSP使用此数据作为:

${empForm.employees}
2. 直接将员工名单放入请求中

request.setAttribute("employees", employeeList);
将employeeList设置为请求的操作类

request.setAttribute("employees", employeeList);
在JSP中:

${employees}

请建议我应该采用什么方法。在Struts 1.3中,哪一个被认为是良好的实践。

两者都是正确的。如果页面需要表单,您可以将列表放在ActionForm中。就我个人而言,我更喜欢在ActionForm中设置,因为它更有条理。

如果您需要编辑数据,最好将其放在ActionForm中,否则没有太大区别