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属性去掉即可。


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