Liferay AJAX请求:找不到portlet请求

时间:2016-06-07 01:07:03

标签: ajax liferay

在Liferay论坛上提问post

我正在尝试使用<portlet:resourceURL>从我的Lifery portlet发出AJAX请求。

index.jsp

<portlet:resourceURL var="search" id="recordId"></portlet:resourceURL>
<a href="#" onclick="ajaxCall('${search}')">CLICK ME</a>
    <script>
    var id = 100;
    function ajaxCall(ajaxUrl){
        $.ajax({
                url : ajaxUrl,
                data : {
                    id: id
                }, 
                type: 'GET',
                dataType : "json",
                success : function(data) {
                       // do stuff on success
               },
              error: function () {
                    //do stuff on error
                    console.log('Error Occurred');
                }
       });
}
    </script>

我的@Controller

@Controller
@PropertySource("classpath:application.properties")
@RequestMapping(value = "VIEW")
public class SearchController {

     @ActionMapping
        public void handleActionRequest(ActionRequest request, ActionResponse response)throws Exception {
            System.out.print("In the Action Mapping Handler");

            return;
        }

        @RenderMapping
        public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response, ModelMap model) {
          return new ModelAndView("index", model);

        }

        @ResourceMapping(value = "search")
        @ResponseBody
        public void getPlan(ResourceRequest request, ResourceResponse response) throws PortalException, SystemException, IOException {

            System.out.println("In the search Controller");
        }
}

但是我收到错误并且不确定原因

org.springframework.web.portlet.NoHandlerFoundException: No handler found for portlet request: mode 'view', phase 'RESOURCE_PHASE', parameters map[[empty]]

请求网址:

http://localhost:8090/portal/web/mySite/home?p_p_id=MyApp_WAR_MyApp&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=recordId&p_p_cacheability=cacheLevelPage&p_p_col_id=column-1&p_p_col_count=1&id=100

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

@ResourceMapping(value =“recordId”)可以像Pankaj所说的那样工作。