<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    記錄、分享

    struts2 當spring遇到json插件時的異常 及解決(引用)

    struts2 當spring遇到json插件時的異常 及解決




    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>

    發生的異常
    org.apache.catalina.core.StandardWrapperValve invoke
    嚴重: Servlet.service() for servlet default threw exception
    java.sql.SQLException: Positioned Update not supported.
    低調的貓(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個properties,其中有個bean是service,而且是在spring framework中已經實例化了的,問題就出在它身上了。于是在struts-config中加入該bean的exclude,再測試,成功了!
    發送action的request后,服務返回JSON數據。

    解決-----------------------------------------------------------------------------------------
    <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 張生 閱讀(1015) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    <2011年6月>
    2930311234
    567891011
    12131415161718
    19202122232425
    262728293012
    3456789

    導航

    統計

    常用鏈接

    留言簿

    隨筆檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 国产在线观a免费观看| 免费看黄福利app导航看一下黄色录像| 韩国免费A级毛片久久| 亚洲精品乱码久久久久久蜜桃 | 国产高清视频在线免费观看| 亚洲精品伊人久久久久| 亚洲免费观看在线视频| 亚洲小视频在线播放| 国产精品入口麻豆免费观看| 亚洲国产精品网站久久| 桃子视频在线观看高清免费完整| 亚洲宅男天堂a在线| 性色av免费观看| 美女被免费网站在线视频免费 | 久久亚洲精品成人777大小说| 国产一级片免费看| 久久久久亚洲AV无码网站| 波多野结衣免费在线| 亚洲中文字幕日本无线码| 免费a级毛片18以上观看精品| 日本在线观看免费高清| 亚洲av无码国产精品夜色午夜| 99爱视频99爱在线观看免费| 国产成人精品日本亚洲专区6| 日本一道综合久久aⅴ免费| 一级女性全黄生活片免费看| 亚洲女初尝黑人巨高清| 国产一卡二卡四卡免费| 麻豆91免费视频| 亚洲av无码专区在线播放| 免费国产黄线在线观看| 免费人妻精品一区二区三区| 亚洲成人动漫在线| 色妞WWW精品免费视频| j8又粗又长又硬又爽免费视频| 国产成人精品日本亚洲网站| 四虎国产精品免费久久| 国产精品免费久久久久影院 | 免费看片在线观看| 国产成人高清亚洲一区久久 | 999在线视频精品免费播放观看|