我想在我的网络应用程序中使用多个视图解析器基于spring mvc
任何人都可以告诉我如何实现这一目标.
我想在我的应用程序中使用JSP和freemarker.请提出一些方法或链接或示例..
所有帮助表示赞赏.
Adhir
我尝试使用2个视图解析器:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.evgeni.dfr.controller" />
<context:annotation-config />
<mvc:annotation-driven />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="cache" value="false" />
<property name="viewClass" value="com.evgeni.drf.faces.FacesView" />
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".xhtml" />
<property name="order" value="1" />
</bean>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
<property name="order" value="0" />
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
应用程序始终只使用最低顺序而不是另一个.在目前的情况下,如果我的控制器返回"someView",The requested resource (/MyProject/WEB-INF/views/someView.jsp) is not available.即使有"pages/someView.xhtml" ,应用程序也会响应.
春季版 - 3.2.3
编辑:如果我在控制器中有2个方法,方法A返回"viewA",方法B返回"viewB".我们在'views'文件夹中有viewA.jsp,在'pages'中有viewB.xhtml.
Case1:UrlBasedViewResolver - > …