ERROR: 'ContentNegotiatingViewResolver'of Spring 3.0.3 MVC Portlet+JSON

倖福魔咒の 提交于 2019-12-06 08:12:18

ContentNegotiatingViewResolver doesn't work with portlets, only servlets.

As a general rule, many servlet API classes in Spring have a portlet equivalent, e.g.

  • org.springframework.web.servlet.HandlerAdapter
  • org.springframework.web.portlet.HandlerAdapter

You have to make sure that you use the right one - the servlet and portlet APIs are completely incompatible.

However, since Spring 2.5, the portlet framework has been neglected (probably because it's very rarely used), and newer parts of the servlet MVC API have not been included in the portlet MVC API.

It would seem that if you want to do what you're trying to do, you're going to have to do a lot of it yourself. You might be able to copy some of the code from ContentNegotiatingViewResolver and related classes.

Check this out. It should work now



<!-- View Resolver -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/test/testJSp/" />
    <property name="suffix" value=".jsp" />
      <property name="order" value="2" />
</bean>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!