ajax回調資料 Structs has detected an unhandled exception 問題

來源:互聯網
上載者:User

標籤:png   text   context   pat   尋找   ima   hand   一個   word   

Structs has detected an unhandled exception

今天算倒黴了,用maven寫的一個項目,竟然出現了以下低級的錯誤,在用ajax修改密碼時,回調的資料竟然是以下的東東。。。。

**************************************************************************************

$.post("${pageContext.request.contextPath}/user_editPassword",{password:NewPass},function(data){
               alert("ajax傳回值:"+data);
               if(data.result == "success"){
                  $.messager.alert("成功提示",data.msg,"info");
               }else{
                  $.messager.alert("失敗提示",data.msg,"error");
               }
               $("#editPwdWindow").window("close");
         });

**********************************************

這裡引用了struts2-json-plugin包

json-default繼承了struts-default

<!-- 修改密碼 -->

<package name="needlogin" extends="json-default">
        <action name="user_*" class="userAction" method="{1}">
            <!-- 修改密碼 -->
            <result name="editPasswordSuccess" type="json">
                <param name="root">map</param>
            </result>
        </action>

</package>

******************************************************************************

private String editPassword() {
        User loginUser = (User) ServletActionContext.getRequest().getSession().getAttribute("user");
        user.setId(loginUser.getId());
      //  通過使用者id修改密碼,如果修改不成功會拋異常      
        Map<String,Object> map=new HashMap<String,Object>();
        try {
          //修改成功
          System.out.println(user.getPassword());
          userService.editPassword(user);
           map.put("result", "success");
           map.put("msg", "修改成功");
           ActionContext.getContext().put("map", map);
    } catch (Exception e) {
         //修改失敗
         map.put("result", "false");
           map.put("msg", "修改失敗,請尋找原因"+ e.getMessage());
           ActionContext.getContext().put("map", map);
    }
       
        return "editPasswordSuccess";
    }

*******************************************

這個問題找了很久,ajax一直訪問不到UserAction這個類,檢查了strut.xml,applicationContext.xml的配置,沒問題

在檢查ajax的訪問路徑,也沒有問題,用firebug清楚能看到訪問的路徑,就是最後到action類的方法時就訪問不了,

然後,就檢查這個方法,很紮心

原來是這個方法我使用了private,恍然大悟

這就是訪問不到的原因,把private改為public,然後就成功了!!!!

ajax回調資料 Structs has detected an unhandled exception 問題

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.