问题描述
我想知道我是否可以在我的调度程序servlet中创建多个 InternalResourceViewResolver
。
I was wondering if i could create a multiple InternalResourceViewResolver
in my dispatcher servlet.
这样的事情,
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
和另一个这样的解析器,
and another view resolver like this ,
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/folder/jsp/"
p:suffix=".jsp" />
我不是指创建多个视图解析器。例如,Tiles,XML视图解析器
I am not referring about creating multiple view resolvers. For ex, Tiles,XML view resolvers
我需要配置两个不同的 InternalResourceViewResolver 作为尝试但我无法清楚地理解它。是否有可能实现?
I need to configure two different InternalResourceViewResolver as tried here but i can't clearly understand it , .Is it possible to achieve ?
提前致谢
推荐答案
不。你可以在你的上下文中只有一个,因为:
No. You can only ever have one of them in your context, because of the same reason mentioned in the javadoc:
InternalResourceViewResolver
总是返回一个答案(因为它只委托给Servlet API,它总是有答案,即使它是错的),所以有两个人不会让你到任何地方,因为第二个将永远不会被咨询。
InternalResourceViewResolver
always returns an answer (because it just delegates to the Servlet API, which always has an answer, even if it's wrong), so having two of them won't get you anywhere, since the 2nd one will never be consulted.
你需要找到另一种重新映射你的JSP视图名称的方法单个解析器。
You'll need to find another way to remap your JSP view names on to a single resolver.
这篇关于创建多个InternalResourceViewResolver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!