記錄、分享

          struts2 當(dāng)spring遇到j(luò)son插件時(shí)的異常 及解決(引用)

          struts2 當(dāng)spring遇到j(luò)son插件時(shí)的異常 及解決




          1 我的Action代碼
          package common.regist.action;
          import com.opensymphony.xwork2.ActionSupport;
          import common.regist.Interface.IRegistService;
          import domain.User;
          public class RegistAction extends ActionSupport {
          private IRegistService service;

          private String responseText;

          private String username = "";

          private User user;

          public IRegistService getService() {
            return service;
          }
          public void setService(IRegistService service) {
            this.service = service;
          }

          public User getUser() {
            return user;
          }

          public void setUser(User user) {
            this.user = user;
          }

          public String validateUserName() {
            if(service.validateUser(username).size()==0)
            {
             this.setResponseText("true");
             return ActionSupport.SUCCESS;
            }
            this.setResponseText("false");
            return ActionSupport.SUCCESS;
          }


          public String execute() throws Exception {
            service.regist(user);
            return super.execute();
          }

          public String getResponseText() {
            return responseText;
          }

          public void setResponseText(String responseText) {
            this.responseText = responseText;
          }

          public String getUsername() {
            return username;
          }
          public void setUsername(String username) {
            this.username = username;
          }

          }

          配置文件里:
          <package name="ajax" extends="json-default" namespace="/login">
            <action name="validateUserName" class="registAction" method="validateUserName">
             <result type="json"></result>
            </action>
            </package>

          發(fā)生的異常
          org.apache.catalina.core.StandardWrapperValve invoke
          嚴(yán)重: Servlet.service() for servlet default threw exception
          java.sql.SQLException: Positioned Update not supported.
          低調(diào)的貓(624767717) 15:04:17
          at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
          at com.mysql.jdbc.ResultSet.getCursorName(ResultSet.java:1917)
          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:220)
          at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:152)
          at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:120)
          at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:302)
          at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:221)
          at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:152)
          at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:120)
          at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:302)
          at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:221)
          at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:152)
          at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:120)
          at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:302)
          at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:221)
          at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:152)
          at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:120)
          at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:302)
          at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:221)
          at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:152)
          at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:120)
          at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:302)
          at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:221)
          at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:152)
          at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:120)
          at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:302)
          at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:221)
          at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:152)
          at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:120)
          at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:302)
          at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:221)
          at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:152)
          at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:120)
          at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:302)
          at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:221)
          at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:152)
          at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:120)
          at com.googlecode.jsonplugin.JSONWriter.write(JSONWriter.java:88)
          at com.googlecode.jsonplugin.JSONUtil.serialize(JSONUtil.java:90)
          at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:119)


          分析---------------------------------------------------------------------------------------
          在我的Action中一共有4個(gè)properties,其中有個(gè)bean是service,而且是在spring framework中已經(jīng)實(shí)例化了的,問題就出在它身上了。于是在struts-config中加入該bean的exclude,再測(cè)試,成功了!
          發(fā)送action的request后,服務(wù)返回JSON數(shù)據(jù)。

          解決-----------------------------------------------------------------------------------------
          <action name="validateUserName" class="registAction" method="validateUserName">
             <result type="json">
               <param name="excludeProperties">      //序列化屬性中排除 service
                               service
             </param>

          </result>
            </action>
            </package>

          posted on 2011-06-09 15:58 張生 閱讀(1019) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          <2011年6月>
          2930311234
          567891011
          12131415161718
          19202122232425
          262728293012
          3456789

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 綦江县| 苍山县| 丹东市| 星子县| 松原市| 广汉市| 威海市| 广河县| 长岛县| 尼勒克县| 廉江市| 凌云县| 贺州市| 淳化县| 康乐县| 手游| 赞皇县| 辽源市| 响水县| 胶州市| 巨野县| 彭山县| 改则县| 五峰| 越西县| 胶州市| 海兴县| 工布江达县| 龙井市| 岢岚县| 城固县| 新河县| 开封县| 遂溪县| 海晏县| 资源县| 华阴市| 长春市| 安溪县| 黄龙县| 天峻县|