---
title: "struts2  升级问题 2"
author: "helloworlda"
date: "2014-02-18T14:22:02Z"
tags: []
categories: ["行业应用"]
slug: "struts2-2"
draft: false
lastmod: "2014-02-18T14:31:24Z"
id: 2018572
url: "https://helloworlda.iteye.com/blog/2018572"
---

## WARN com.opensymphony.xwork2.ognl.OgnlValueStack异常的解决办法

(2012-07-14 10:49:09)

[![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)转载*▼*](/admin/blogs/javascript:;)

标签： 

### [解决办法](http://search.sina.com.cn/?c=blog&q=%BD%E2%BE%F6%B0%EC%B7%A8&by=tag)

 

### [属性](http://search.sina.com.cn/?c=blog&q=%CA%F4%D0%D4&by=tag)

 

### [提交](http://search.sina.com.cn/?c=blog&q=%CC%E1%BD%BB&by=tag)

 

### [表单](http://search.sina.com.cn/?c=blog&q=%B1%ED%B5%A5&by=tag)

 

### [开发过程](http://search.sina.com.cn/?c=blog&q=%BF%AA%B7%A2%B9%FD%B3%CC&by=tag)

 

### [it](http://search.sina.com.cn/?c=blog&q=it&by=tag)

分类： [Java专区](http://blog.sina.com.cn/s/articlelist_1762104573_2_1.html)

WARN com.opensymphony.xwork2.ognl.OgnlValueStack:60 - Error setting expression 'ssc.x' with value '[Ljava.lang.String;@28d320d6'

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) 

的解决办法

Struts2这个异常是在提交表单的时候发生的，乍一看以为是Struts2类型转换的错误，但是程序中又压根儿没有用到Struts2的类型转换，而且前台页面index.jsp中也没有设置x,y这些参数；且这个错误并不会影响程序的正常运行，找了很久，最后发现是提交按钮的缘故，提交按钮引用的是一个图片，如下：

&lt;input id="submit" type="image" name="ssc" src="asserts/images/5.jpg"/&gt;

由于表单提交中设置了name属性，所以struts2会进行接收相应的值，查找它的set 和 get方法，而action里面没有这个name值的，所以才出现了如上错误。可以这样写：

&lt;input id="submit" type="image"  src="asserts/images/5.jpg" /&gt;

将name属性去掉即可。

其实，在struts.xml文件里可以配置"struts.devMode"属性。

当struts.devMode = true时，使用struts在默认配置下对任何提交到action的参数强制需要setter方法，html表单数据中有和action属性匹配不上的参数名时就会提示这样的信息。所以，在开发过程中将这个属性设为true还是很好的，它可以帮我们发现一些可能出现但又被我们忽视的问题，犯的“错误”越多，才能积累很多的经验。