使用struts2 json插件 :
Action 中 :
[code="java"]
public void setOaAssetDeviceVos(List oaAssetDeviceVos) {
System.out.println("setOaAssetDeviceVos 执行 。。。。");
System.out.println("oaAssetDeviceVos == " + oaAssetDeviceVos);
System.out.println("oaAssetDeviceVos.getClass().getName() == " + oaAssetDeviceVos.getClass().getName());
int len = oaAssetDeviceVos.size();
System.out.println("len = " + len);
for(int i=0;i<len;i++){
System.out.println(i + " , type == " + oaAssetDeviceVos.get(i).getClass().getName());
System.out.println(i + " , oaAssetDeviceVos.get(i) = " + oaAssetDeviceVos.get(i));
}
this.oaAssetDeviceVos = oaAssetDeviceVos;
}
public List<OaAssetDeviceVo> getOaAssetDeviceVos() {
return oaAssetDeviceVos;
}
[/code]
这时候我在 客户端 接收到 :
[code="java"]
[{"card":"未填","title":"未填","type":"未填","xinghao":"未填","pinpai":"未填","timeBuy":"2009-01-04T13:12:07"},{"card":"未填","title":"未填","type":"未填","xinghao":"未填","pinpai":"未填","timeBuy":"2009-01-04T13:12:07"},{"card":"未填","title":"未填","type":"未填","xinghao":"未填","pinpai":"未填","timeBuy":"2009-01-04T13:12:07"}][/code]
现在我想 把 客户端的这种格式传回 Action 中 :
[code="java"]
store.load({params:{oaAssetDevices: [{"card":"未填","title":"未填","type":"未填","xinghao":"未填","pinpai":"未填","timeBuy":"2009-01-04T13:12:07"}],ids:this.ids}});
[/code]
结果 :
Action 中的 setOaAssetDeviceVos 方法被执行 ,但 后台报 :
[code="java"]
setOaAssetDeviceVos 执行 。。。。
oaAssetDeviceVos == [ognl.NoConversionPossible]
oaAssetDeviceVos.getClass().getName() == com.opensymphony.xwork2.util.XWorkList
len = 1
0 , type == java.lang.String
0 , oaAssetDeviceVos.get(i) = ognl.NoConversionPossible
___ Could not find action or result
No result defined for action module.oa.action.OaAssetActionJ and result input -
action - file:/D:/project/tianbao/oa/web/WEB-INF/classes/base/struts2.xml:31:82
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(Defaul
ActionInvocation.java:350)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultAction
nvocation.java:253)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(
alidationInterceptor.java:150)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterc
ptor.doIntercept(AnnotationValidationInterceptor.java:48)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercep
(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(Defaul
ActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(Defaul
ActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTi
erStack.java:455)
[/code]
问题集中在 js 中的 json 数据 怎么 转成 自定义的 后台 java对象。
哪位了解啊 ?