2012-03-30 68 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'