我想使用DispatcherPortlet類使Spring MVC 3.0.3 portlet具有JSON支持。所以,我在spring上下文文件中添加了以下配置。錯誤:'ContentNegotiatingViewResolver'Spring 3.0.3 MVC Portlet + JSON
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
text/html的
沒有這個,如果我使用'InternalResourceViewResolver',那麼它運行良好,我可以使用portlet。但是在定義這個bean的時候,我在tomcat啓動時遇到了以下錯誤。
我搜索了一下,找到一個鏈接,聲明這個帶有JSON的bean只能在最新的spring vesion中使用servlet。請檢查鏈接。
http://jira.springframework.org/browse/SPR-7344(JSON問題Portlet的...)
也請檢查下面粘貼的錯誤。幫助我... 謝謝。
:ERROR:
java.lang.IllegalArgumentException: Object of class [org.springframework.web.portlet.context.PortletRequestAttributes] must be an instance of class org.springframework.web.context.request.ServletRequestAttributes
,請查看日誌
Caused by: java.lang.IllegalArgumentException: Object of class [org.springframework.web.portlet.context.PortletRequestAttributes] must be an instance of class org.springframework.web.context.request.ServletRequestAttributes
at org.springframework.util.Assert.isInstanceOf(Assert.java:337)
at org.springframework.util.Assert.isInstanceOf(Assert.java:319)
at org.springframework.web.servlet.view.ContentNegotiatingViewResolver.resolveViewName(ContentNegotiatingViewResolver.java:363)
at org.springframework.web.portlet.DispatcherPortlet.resolveViewName(DispatcherPortlet.java:1110)
at org.springframework.web.portlet.DispatcherPortlet.render(DispatcherPortlet.java:1052)
at org.springframework.web.portlet.DispatcherPortlet.doRenderService(DispatcherPortlet.java:761)
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:522)
您好,請您粘貼處理方法?我似乎無法使其工作http://stackoverflow.com/q/4498266/306488。我真的很感激,如果你幫我出來 – lisak 2010-12-21 13:05:52
我讀過這兩個線程:http://forum.springsource.org/showthread.php?t=83673 ... http://forum.springsource.org/showthread .php?t = 97005,但仍不清楚應該如何完成。尤其是響應部分,如何在春季處理程序 – lisak 2010-12-21 13:23:08