开发者

Spring Web: Correct way to have a single default ViewResolver

What is the best开发者_运维知识库 way to have every request be sent to a single ViewResolver - specifically in this case a JsonView?

Was thinking this:

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
    <property name="prefix" value="*" />
</bean>

but, is there something better/easier?


You've misunderstood what a ViewResolver is for. They're not there to service requests (that's what controllers are for), they're there to turn view names (as returned by the controller) into views (e.g. JSPs). The prefix and suffix properties are used to assemble the path to the view.

If you could describe what problem you're trying to solve, we can show you how.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜