后台Action中有String数组expPros:
private String[] expPros;
///get set
在form表单中试图通过以下方式向action中expPros赋值时:
<input type="text" name="expPros[0]" value="extProp1_VALUE">
<input type="text" name="expPros[1]" value="extProp2_VALUE">
<input type="text" name="expPros[2]" value="extProp3_VALUE">
结果报错:
引用
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '[Ljava.lang.String;': Could not resolve matching constructor
如果写成:
<input type="text" name="expPros[]" value="extProp1_VALUE">
<input type="text" name="expPros[]" value="extProp2_VALUE">
<input type="text" name="expPros[]" value="extProp3_VALUE">
就不会抛上面错误了,但三个input输入框的值不会被赋给expPros:
引用
01/15/2011 01:40:19.203 ERROR ParametersInterceptor,204 - ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'expPros[]' on 'class com.sgai.itms.equipment.web.ItmsEquipDetailsAction: Error setting expression 'expPros[]' with value '[Ljava.lang.String;@2a519b'
String[] arr = request.getParameterValues("expPros");
///arr为null
具体原因:
struts2 OGNL实例化数组的问题.
http://blog.csdn.net/fuliangliang/archive/2007/10/15/1826560.aspx引用
Struts doesn't support array creation due to an issue with size determination. Kinda what I though earlier. So, I've changed it over to use a List<Integer> and that works fine.
The docs are very misleading on this point. I'd be more than happy to clean up the type conversion doc and also create an collection handling doc to help folks out with this issue. Let me know if I can help out at all.
据此得出,通过struts2的action(或直接使用request)的方式向后台传java 数组的正确方式是各个input的name都取成后台数组名即可(如这里的expPros),
不可以加[]:
引用
三个input的值可以被传给Action中的数组expPros;并且也可以通过request.getParameterValues("expPros")的方式得到一个String数组
<input type="text" name="expPros" value="extProp1_VALUE">
<input type="text" name="expPros" value="extProp2_VALUE">
<input type="text" name="expPros" value="extProp3_VALUE">
String[] arr = request.getParameterValues("expPros"); /// 同Action的属性expPros一样,arr也为"[extProp1_VALUE, extProp2_VALUE, extProp3_VALUE]"
分享到:
相关推荐
在使用Maven构建Java项目时,可能会遇到这样一个错误:“Failed to execute goal on project …: Could not resolve dependencies for project …”。这个错误通常表明Maven在构建过程中遇到了依赖解析问题,无法...
myeclipse创建maven工程报错 Could not resolve
在升级Android Studio到特定版本,如3.6.1时,可能会遇到一些问题,其中一个常见的问题是“Could not resolve all artifacts for configuration ‘:classpath’”。这个错误表明Gradle无法解析所有配置的依赖项,这...
按官方配置好了 developer.... Could not resolve com.huawei.agconnect 解决方法:把相应的插件用本地化安装 agconnect-crash-symbol-lib-1.6.1.300.jar agconnect-apms-plugin-1.6.1.300.jar agcp-1.6.1.300.jar。
sslscan的工作原理是模拟不同的客户端,尝试与服务器建立连接,并测试服务器支持的所有SSL/TLS特性。它会检测以下关键点: 1. **协议支持**:sslscan会检测服务器是否支持SSLv2、SSLv3、TLSv1.0、TLSv1.1、TLSv1.2...
Error:Could not resolve all files for configuration ‘:app:debugCompileClasspath’. > Could not resolve com.android.support:appcompat-v7:26.0.0-beta1. Required by: project :app > Could not ...
主要介绍了解决Unable to access 'https://gitee.com/自己的项目/': Could not resolve host: gitee.com问题,需要的朋友可以参考下
如下所示: 拷贝远程服务器的文件到本地: ...拷贝本地文件到远程服务器: ...以上这篇linux采用scp命令拷贝文件到本地,拷贝本地文件到远程服务器的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家...
Could not find module 'D:\codna\Library\bin\geos_c.dll'Could not find module 'D:\codna\Library\bin\geos_c.dll'Could not find module 'D:\codna\Library\bin\geos_c.dll'
使用Eclipse整合Maven后,创建项目时报错:Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories
Android Studio更新3.6.3之后出现Could not resolve all artifacts for configuration ‘:classpath’.问题你是否和我一样,只因在人群中多看了他一眼?![在这里插入图片描述]...
###通过hql以对象的boolean类型字段作为条件进行查询遇到的问题: 这是在做项目时遇到的一个问题,当时琢磨了蛮久的,觉得有点神奇吧,特地做了一个小demo作记录 po: 成员变量为private boolean isStudent; 数据库:手动...
在本篇文章里小编给大家分享的是关于docker容器调用yum报错的解决办法,有兴趣的朋友们可以参考下。
Could not resolve dependencies for project org.apache.flink:flink-avro-confluent-registry:jar:1.15.3: Could not find artifact io.confluent:kafka-schema-registry-client:jar:6.2.2 in maven 安装本地...
QueryException: could not resolve property 当执行HQL查询或criteria查询时,如果指定的属性名在目标类中不存在,或者属性路径有误,就会抛出此异常。例如,正确的查询可能是`from Category category where ...
jar包,官方版本,自测可用
StatusBarUtil A util for setting status bar style on Android App. It can work above API 19(KitKat 4.4). 中文版点我 Sample Download StatusBarUtil-Demo ChangeLog ...Add the dependencies to your build....
每个区域都有自己的Nessus ID,需要向各区域负责人索取相应ID。建议使用虚拟机安装,然后离线升级使用。 Nessus扫描工具的建立包括自定义扫描策略和高级扫描方法。在自定义扫描策略中,需要设置好策略的名称,建议...