在Liferay 6.1中不使用SpringMVC portlet调用Ajax方法

时间:2012-03-30 08:25:09

标签: jquery spring-mvc liferay

我在Liferay 6.1中使用SpringMVC portlet。我试图从tha jsp进行ajax调用,但该方法没有被调用,我得到如下错误

无法加载服务器响应的资源,状态为404(未找到)

我的jsp ajax方法是

jQuery.ajax({
    url:'<portlet:resourceURL id="ajax" ></portlet:resourceURL>',
                data: {id:data},
                type: 'POST',
                datatype:'json',
                success: function(respData) {

                    alert(respData);
                    jQuery('#farmerProfile').html(respData);
                }
            }); 

和控制器类中的servResource方法签名是

@ResourceMapping(value="ajax")
public void serveResource(
        PortletConfig config, ResourceRequest request, ResourceResponse response)


        throws Exception {

我的控制器类正在实现

   org.springframework.web.portlet.mvc.Controller interface

有人能说清楚吗? 感谢

2 个答案:

答案 0 :(得分:3)

ajax POST由Portlet processAction处理。 ajax GET由serverRequest处理。

因此,将'type'更改为'POST'到'GET'

答案 1 :(得分:1)

“Portlets-in-action”一书中的sample portlet可用作调试代码的参考。

希望这有帮助。

相关问题