后台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]"
分享到:
相关推荐
[INFO] ———————————————————————— [INFO] Reactor Summary for demo 0.0.1-SNAPSHOT: [INFO] [INFO] demo ……………………………………….. FAILURE [18:18 min] [INFO] admin-service ...
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ‘:classpath’. 提示错误:Read Time out ...
myeclipse创建maven工程报错 Could not resolve
网上下载的开源SSL服务器扫描代码。 依赖与openssl库。 超级好用啊,精华之作。
按官方配置好了 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。
主要介绍了解决Unable to access 'https://gitee.com/自己的项目/': Could not resolve host: gitee.com问题,需要的朋友可以参考下
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 ...
hive 开发UDF 使用maven工程 引发jar包缺失 hive 开发UDF 使用maven工程 引发jar包缺失
Microsoft OLE DB Provider for ODBC Drivers 错误'80040e4d'[Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the connect identifier specified. 使用PL-SQL Developer能连接上Oracle,但是ASP+ODBC连不上...
Could not resolve all dependencies for configuration ‘:classpath’. Could not resolve com.android.tools.build:gradle:2.1.2. ………. 等6个error 上网百度csdn,结果试下各种方法,依旧没用。 搞了一天,...
如下所示: 拷贝远程服务器的文件到本地: ...拷贝本地文件到远程服务器: ...以上这篇linux采用scp命令拷贝文件到本地,拷贝本地文件到远程服务器的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家...
使用Eclipse整合Maven后,创建项目时报错:Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories
主要给大家介绍了关于Android添加glide库报错Error: Failed to resolve: com.android.support:support-annotations:26.0.2的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值...
###通过hql以对象的boolean类型字段作为条件进行查询遇到的问题: 这是在做项目时遇到的一个问题,当时琢磨了蛮久的,觉得有点神奇吧,特地做了一个小demo作记录 po: 成员变量为private boolean isStudent; 数据库:手动...
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 安装本地...
安卓调取usb摄像头的工具类,包含了之前版本删除掉的类,解决:libusbcamera@debug/compileClasspath': Could not resolve com.serenegiant:common:1.5.20.报错问题,需要配合repository文件夹使用
Android Studio更新3.6.3之后出现Could not resolve all artifacts for configuration ‘:classpath’.问题你是否和我一样,只因在人群中多看了他一眼?![在这里插入图片描述]...
Could not resolve all files for configuration ':jcore-react-native:lintClassPath'. > Could not download groovy-all.jar (org.codehaus.groovy:groovy-all:2.4.15) > Could not get resource '
jar包,官方版本,自测可用
solcJ-all-0.4.25.jar /home/user_name/.m2/repository/org/ethereum/solcJ-all/0.4.25/solcJ-all-0.4.25.jar 这是编译过程从外网下载下来的。