views:

31

answers:

0

Hi all,

I am trying to use the library spring-json.1.3.1 in a project that has been done with Liferay 5.1.2 which includes Spring 2.5.

Following the project website instructions, I managed to make the request hit in my controller, but at the moment of returning the json object back through the modelAndView object it fails with the following error:

java.lang.IllegalArgumentException at com.liferay.portlet.MimeResponseImpl.setContentType(MimeResponseImpl.java:162)

I have checked Liferays source code, and it checks that contentType that its being set is in a harcoded list,if it not it will throw a IllegalArgumentException that it is exactly what os happening.

This is my view resolver code:

<bean id="xmlFileViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">

/WEB-INF/context/views.xml 1

My views.xml code:

<beans>
   <bean name="jsonView" class="org.springframework.web.servlet.view.json.JsonView"/> 

And my controller:

@SuppressWarnings("unchecked")

@Override public ModelAndView handleRenderRequest(RenderRequest arg0, RenderResponse arg1) throws Exception {

Map model = new HashMap(); model.put("firstname", "Peter"); model.put("secondname", "Schmitt");

     return new ModelAndView("jsonView", model);

}

Any ideas?