【发布时间】:2010-07-06 05:53:14
【问题描述】:
我想使用带有 JSON 支持的 DispatcherPortlet 类制作 Spring MVC 3.0.3 portlet。所以,我在 spring 上下文文件中添加了以下配置。
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
文本/html
如果没有这个,如果我只使用“InternalResourceViewResolver”,那么它运行良好并且我能够使用 portlet。但是定义了这个bean后,我在tomcat启动时遇到了以下错误。
我四处搜索并找到一个链接,说明这个带有 JSON 的 bean 仅适用于最新春季版本中的 servlet。也请检查链接。
http://jira.springframework.org/browse/SPR-7344(portlet 的 JSON 问题...)
另外请检查下面粘贴的错误。帮我... 谢谢。
:错误:
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)
【问题讨论】:
-
嗨,您能粘贴处理程序方法吗?我似乎无法让它工作 stackoverflow.com/q/4498266/306488 。如果您能帮助我,我将不胜感激
-
我已经阅读了这两个线程:forum.springsource.org/showthread.php?t=83673 ... forum.springsource.org/showthread.php?t=97005,但仍然不清楚应该如何完成。尤其是响应部分,spring handler中如何响应那个请求
标签: java json spring spring-mvc portlet