我送這個參數來我的支柱作用OGNL數組和列表索引
CDATA [1] = BAR
在我的行動,我感興趣的指數值。 我限定的吸氣/設定器對,用於CDATA
作爲OGNL documentation表明:
public void setCdata(int index, String value){
LOG.info("setData; key="+ key +"; value="+ value);
// store index and value;
}
public String getCdata(int index){
return null; // don't really need a setter
}
這是例外我得到:
2013-04-29 15:38:49,792 [http-apr-8080-exec-3] WARN com.opensymphony.xwork2.util.logging.commons.CommonsLogger.warn(CommonsLogger.java:60) - Error setting expression 'cdata[1]' with value '[Ljava.
lang.String;@4223d2a4'
ognl.OgnlException: target is null for setProperty(null, "1", [Ljava.lang.String;@4223d2a4)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2309)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.ASTChain.setValueBody(ASTChain.java:227)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.Ognl.setValue(Ognl.java:737)
...
如果我定義了一個公共成員變量String[] cdata = new String[1000]
我沒有看到任何在我的日誌中的例外,但我的二傳手也沒有被調用。如果該成員變量是私人的,我再次得到另一個異常。
你能指點我提到的文檔嗎? – 2013-04-30 05:54:05
@LukaszLenart:我相信OP指的是這個文檔http://commons.apache.org/proper/commons-ognl/language-guide.html#Indexing。 – 2013-04-30 08:23:22