WARN com.opensymphony.xwork2.ognl.OgnlValueStack:60

錯誤如下:

ognl.OgnlException: target is null for setProperty(null, "x", [Ljava.lang.String;@28d320d6)

ognl.OgnlException: target is null for setProperty(null, "y", [Ljava.lang.String;@32a88bc2)


解決方法:

其實我的頁面裏並沒有x,y屬性,找了很久,才發現是提交按鈕的問題,我的提交按鈕引用的是一個圖片,設置如下:

<input id="submit" type="p_w_picpath" name="p_w_picpathfield2.x" src="p_w_picpaths/button.jpg"/>


由於表單提交中設置了name屬性,所以struts2會進行接收相應的值,查找它的set 和 get方法,而action裏面沒有這個name值的,所以纔出現瞭如上錯誤。可以這樣寫:

<input id="submit" type="p_w_picpath" src="p_w_picpaths/button.jpg" />

將name屬性去掉即可。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章