在Spring + Struts2中,数据从action返回到页面时有时会报如下异常:
严重: Servlet.service() for servlet default threw exception
java.sql.SQLException: 不支持的特性: getCursorName
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.BaseResultSet.getCursorName(BaseResultSet.java:37)
at com.mchange.v2.c3p0.impl.NewProxyResultSet.getCursorName(NewProxyResultSet.java:545)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:224)
at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161)
at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:127)
at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:323)
at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:225)
at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161)
at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:127)
at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:323)
at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:225)
at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161)
at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:127)
at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:323)
at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:225)
at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161)
原因:action中存在了已经被实例化的属性,而这些属性在生成json的时候是不合法的,就会报错。
解决方法:
1.在action中去掉该属性的get方法。
2.在struts.xml中做如下配置:
<action name="userStat" class="trendStatAction" method="userStatChart"> <result type="json"> <param name="excludeProperties">trendStatService</param> </result> </action>去掉该参数的返回。