<s:doubleselect 的使用-不支持EL表达式,需要使用OGNL来动态赋值-could not be resolved as a collection/array/map/enumerati
来源:互联网 发布:java spring 异步调用 编辑:程序博客网 时间:2024/05/29 03:40
1、问题描述:
使用 struts2 设置级联下拉菜单,需要从后台数据库动态搜索下拉列表的选项,使用<s:doubleselect 标签时发现无法使用EL表达式 即 ${"name"} 动态赋值,报错
class org.apache.jasper.JasperException:tag 'doubleselect', field 'list', name 'cooperateType': The requested list key '#bs.keySet()' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
2、问题分析:
网上查询之后,说struts2 在某个版本后不再支持EL表达式赋值,而是需要使用ognl 表达式了,类似于 #request.name 、#session.name
3、问题解决
第一步:
在非动态赋值下的<s:doubleselect 标签 的使用,下面的例子中对样式做了微调,关于样式调整请参考点击打开链接
css样式
<style type="text/css">.doubleselecth br{display: none;}</style>
<s:doubleselect 标签 的使用必须在 <s:form 中
<span class="doubleselecth"><s:set name="bs2" value="#{'业务分类':{'渠道来源'<span style="font-family: Arial, Helvetica, sans-serif;">},'WAP直销':{'长春市','吉林市','延吉市','通化市'},'链接推广':{'青岛市','滨州市'},'后台对接':{'沈阳市','大连市'}}"></s:set></span><span style="white-space:pre"></span><s:set name="bs" value="#bs"></s:set><s:form id="formfdoubleselect">渠道选择:<s:doubleselect doubleCssStyle="width:100px;" cssStyle="width:100px;" name="cooperateType" doubleList="#bs[top]" list="#bs.keySet()" doubleName="channelname" ></s:doubleselect></s:form></span>
第二步:
动态赋值下的<s:doubleselect
java部分的代码提供setter和getter方法
参数的形式必须是Map<String,List> ,关于Map的无序问题请参考 点击打开链接
private Map<String,List> l2;//getter和setter 方法public Map<String, List> getL2() {return l2;}public void setL2(Map<String, List> l2) {this.l2 = l2;}
参数的组织,规则是,Map是LinkedHashMap,这样Map是有序的,然后键值对的key是String,value是list,key最后就是级联列表的第一个下拉框内容,value是每个首选项的子选项,即第二个下拉框显示的内容
//查询目前所有的 渠道名、项目分类List<Object []> l=bcCooperateService.getChannelname_cooperateTypeAll();//业务分类 渠道来源 全部List listx=new ArrayList();listx.add("渠道来源");//业务分类//WAP直销 请选择 cooperateType=00List list00=new ArrayList();list00.add("请选择");//WAP直销//后台对接 请选择 cooperateType=01List list01=new ArrayList();list01.add("请选择");//后台对接//链接推广 请选择 cooperateType=02List list02=new ArrayList();list02.add("请选择");//链接推广//特殊账号 请选择 cooperateType=03List list03=new ArrayList();list03.add("请选择");//特殊账号//合作方式 :00-(WAP直销)网销配置,非合作;01-(后台对接)接口方式;02-(链接推广)链接推广;03-(特殊账号)特殊账号//{'业务分类':{'渠道来源',吉林','辽宁','河北','山东','山西','北京','上海'},'WAP直销':{'请选择'},'后台对接':{'吉林','辽宁'},'链接推广':{'请选择','河北','山东','山西','北京'},'特殊账号':{'请选择','上海'}}for(Object[] obj:l){if("00".endsWith((String) obj[0])){listx.add(obj[1]);list00.add(obj[1]);}else if("01".endsWith((String) obj[0])){listx.add(obj[1]);list01.add(obj[1]);}else if("02".endsWith((String) obj[0])){listx.add(obj[1]);list02.add(obj[1]);}else if("03".endsWith((String) obj[0])){listx.add(obj[1]);list03.add(obj[1]);}} l2=new LinkedHashMap(); l2.put("业务分类", listx); l2.put("WAP直销", list00); l2.put("后台对接", list01); l2.put("链接推广", list02); l2.put("特殊账号", list03);
JSP页面部分,需用ognl 语言获取后台传值
<span class="doubleselecth"><s:form id="formfdoubleselect"><s:set name="bs" value="#request.l2"></s:set>渠道选择:<s:doubleselect doubleCssStyle="width:100px;" cssStyle="width:100px;" name="cooperatetype" doubleList="#bs[top]" list="#bs.keySet()" doubleName="channelname" ></s:doubleselect></s:form></span>
- <s:doubleselect 的使用-不支持EL表达式,需要使用OGNL来动态赋值-could not be resolved as a collection/array/map/enumerati
- could not be resolved as a collection/array/map/enumeration/iterator type的异常处理
- 关于The requested list key 'map' could not be resolved as a collection/array/map/enumera...
- Struts2 :could not be resolved as a collection/array/map/enumeration/iterator type
- The requested list key 'deptlist' could not be resolved as a collection/array/map/enumeration/iterat
- The requested list key '#request.localprovi' could not be resolved as a collection/array/map/enumera
- The requested list key 'deptList' could not be resolved as a collection/array/map/enumeration/iterat
- 报错处理:could not be resolved as a collection/array/map/enumeration/iterator type
- 关于struts2的checkboxlist、select等标签发生could not be resolved as a collection/array/map/enumeration/iterat
- The requested list key 'map' could not be resolved as a collection/array/map/enumeration/iterator ty
- Select标签出现了The requested list key 'noticeType' could not be resolved as a collection/array/map/enume
- The requested list key 'list' could not be resolved as a collection/array/map/enumeration/iterator t
- 关于struts2的checkboxlist、select等标签发生could not be resolved as a collection/array/map/enumeration/iterator type异常的记录
- The requested list key 'map' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or peopl
- The requested list key could not be resolved as a collection。。。。
- 使用EL表达式正确情况下报错:javax.servlet.jsp cannot be resolved to a type
- tag 'select', field 'list', name 'did': The requested list key '#dList' could not be resolved as a c
- tag 'select', field 'list', name 'did': The requested list key '#id' could not be resolved as a c
- java数组排序示例(冒泡排序、快速排序、希尔排序、选择排序)
- 2014-10-15-函数--StaticMesh运动
- HDU1370-Biorhythms
- HTML与CSS--------居中问题
- js中应用protocol buffer
- <s:doubleselect 的使用-不支持EL表达式,需要使用OGNL来动态赋值-could not be resolved as a collection/array/map/enumerati
- 多校训练(三)
- 黑马Android:生成xml文件
- Vue.js 快速搭建
- iOS/NSUserDefaults详解
- Java二维码的制作
- 001java面试笔记——【java基础篇】面试总结的java面试题
- Android导航中Fragment里实现ViewPager滑动和RadioButton单击事件
- 数论