2012-03-30 67 views
2

我在Liferay 6.1中使用SpringMVC portlet。我试图让从Tha JSP Ajax调用,但该方法没有得到所谓的,我得到了如下错误在Liferay 6.1中没有使用SpringMVC portlet调用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 

任何人都可以看到它吗? 谢谢

回答

1

这个sample portlet来自“Portlets-in-action”一书,可以作为参考来调试你的代码。

希望这会有所帮助。

3

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

因此,将您的'类型'从'POST'更改为'GET'