来自Spring MVC Liferay 6.1门户的Ajax调用

时间:2012-03-30 13:14:25

标签: ajax liferay-6

我们正在使用Liferay 6.1的SpringMVC portlet框架来开发门户。我们面临的当前问题是我们无法通过来自jsp页面的ajax调用来调用控制器类中的servResouce方法。

任何人都可以指出解决方案。

1 个答案:

答案 0 :(得分:0)

在Spring控制器中,将资源方法定义为

Public ModelAndView serveResource(ResourceRequest req, ResourceResponse res)
{
  ...
  res.setContentType("application/json; charset=...");
  return new ModelAndView("res_page", model);
}

并设置res_page.jsp响应页面,其中包含:

<% page contentType="text/html; charset=..." %>
<%-- text/html has no effective effect on your response contentType --%>
<% (your taglibs) %>
{
  (your data)
}