struts选择具有数组列表值的标记 [英] struts select tag with values of a array list

查看:92
本文介绍了struts选择具有数组列表值的标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个简单的struts应用程序。在我的JSP中,我有一个下拉列表框(使用 s:select 标签)。我需要在动作类中使用arraylist值填充值。我怎样才能做到这一点? structs.xml 文件需要进行哪些更改才能完成此操作?

I am developing a simple struts application. In my JSP I have a dropdown list box (using s:select tag). I need to fill the values with a arraylist values in the action class. How can I do that? what changes needed in the structs.xml file for complete this?

JSP:

<s:select name="department" label="" list="departmentlist"  headerKey="-1" headerValue="Select Department">

行动类:

private List<String> departmentlist = new ArrayList<String>();

public String xyz()
{
    departmentlist.add("aaa");
    departmentlist.add("bbb");
    departmentlist.add("ccc");
    departmentlist.add("ddd");
    return "success";
}


推荐答案

错误


请求的列表键'departmentlist'无法解析为
集合/ array / map / enumeration / iterator类型。例如:people或
人。{name} - [unknown location]

"The requested list key 'departmentlist' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] "

表示选择 tag无法将 departmentlist 解析为集合。这是一个OGNL表达式,它试图在值堆栈中找到 departmentlist ,如果找不到或包含 null 引用选择标签会抱怨。当您呈现选择标记时,请确保列表位于值堆栈中并进行初始化。请参阅示例此处

means that the select tag is not able to resolve departmentlist as a collection. It is an OGNL expression which is trying to find the departmentlist in the value stack and if it not found or contains a null reference the select tag will complain. When you render the select tag make sure the list is in the value stack and is initialized. See the example here.

这篇关于struts选择具有数组列表值的标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆