Spring-mvc liferay portlet app中的Ajax帖子失败了

时间:2014-02-03 20:11:14

标签: jquery ajax spring-mvc liferay portlet

我有一个liferay应用程序而不是运行正常 我试图向服务器发送一个ajax帖子,但它失败了 实际上服务器响应正常,我可以在firefox开发人员工具中看到响应 但是在调试时我只得到Exception“typeError”

他是我的客户端和服务器代码

function getChildClaims(father){
    var value = father.value;
    var url  = $("#ajaxUrl").val();

    $.post(url,{'fatherId' : value})
    .success(function(){
            alert("good");
    })
    .error(function(xhr,textStatus,errorThrown){
            alert(xhr.responseText);
    });

}

和我的服务器代码

@RequestMapping(params="action=getChildClaimsAjax")
    public void getChildClaims(ResourceRequest request,ResourceResponse response) throws NumberFormatException, EcareException_Exception, IOException{
            List<CustomerClaim> childClaims =ServiceFactory.getCustomerService().getClaimByFatherId(Integer.parseInt(request.getParameter("fatherId")));
            Gson gson = new Gson();
            String json = gson.toJson(childClaims);
            PrintWriter out = response.getWriter();
            out.write(json);
            out.flush();
            out.close();
    }

1 个答案:

答案 0 :(得分:1)

在你所指的jsp.jspf中使用<portlet:resourceURL/>作为ajaxURL(在你的情况下)。

使用@ResourceMapping代替@RequestMapping注释,此更改将解决您的问题。

相关问题