我有一个代码
@RenderMapping
public ModelAndView model(RenderRequest renderRequest, ModelMap map) {
map.put("form", form);
ModelAndView view = new ModelAndView("view", map);
PortletSession portletSession = renderRequest.getPortletSession(true);
if(portletSession != null) {
MappingJacksonJsonView v = new MappingJacksonJsonView();
view.setView(v);
view.addObject("dataListCustomer", portletSession.getAttribute("listCustomer"));
}
init(renderRequest, view);
return view;
}
我有一个错误:
java.lang.IllegalArgumentException: application/json is not a supported mime type
at com.liferay.portlet.MimeResponseImpl.setContentType(MimeResponseImpl.java:159)
错误是由view.setView(v);
如何将 listCustomer 添加到 JSON?在 listCustomer 我有一个 ModelMap
我有代码:
@ResourceMapping(value="customer")
public ModelAndView customer(
ResourceRequest req,
ResourceResponse res) {
log.debug("List Customer Resource: " + context.getCustomer());
ModelAndView mav = new ModelAndView();
MappingJacksonJsonView v = new MappingJacksonJsonView();
v.setBeanName("ajaxResult");
mav.setView(v);
mav.addObject("customer", context.getCustomer());
return mav;
}
客户在@ActionMapping 函数中设置,没问题。
在 JSP 中,我有:
<portlet:resourceURL escapeXml="false" id="customer" var="customer"/>
如何调用@ResourceMapping 函数?因为我 log.debug("List Customer Resource: " + context.getCustomer());
在日志中看不到结果。