您的位置:首页 > 运维架构

ognl.OgnlException: source is null for getProperty(null, "0")

2016-06-13 17:15 786 查看

Java Web错误

ognl.OgnlException: source is null for getProperty(null, “0”)错误。

jQuery在发送ajax请求时,如果请求的参数里有数组对象,后台的Struts2在用List作为接收对象的时候,会报OGNL错误。

原因

jQuery对数组的解析后台Struts2的OGNL解析错误相冲突。

解决办法

1、对Struts2等框架来说,最简单的解决办法就是将其ajax的traditional属性设为true即可

$.ajaxSettings.traditional=true;


2、在数组外层套一个 $.param() 函数,例如:

$.ajax({
url: _url,
type: "post",
data: $.param(_param, true),
dataType: "json",
……
});


错误信息

17:08:37,015  WARN OgnlValueStack:49 - Error setting value
ognl.OgnlException: source is null for getProperty(null, "0")
at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1638)
at ognl.ASTProperty.getValueBody(ASTProperty.java:92)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
at ognl.SimpleNode.getValue(SimpleNode.java:210)
at ognl.ASTChain.setValueBody(ASTChain.java:168)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
at ognl.SimpleNode.setValue(SimpleNode.java:246)
at ognl.Ognl.setValue(Ognl.java:476)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:155)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:143)
…………
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: