Spring-json problem in Liferay with Spring 2.5

Posted by Jesus Benito on Stack Overflow See other posts from Stack Overflow or by Jesus Benito
Published on 2010-06-17T17:19:42Z Indexed on 2010/06/17 17:23 UTC
Read the original article Hit count: 515

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about JSON

Related posts about spring