Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple View resolvers in spring mvc

I want to use multiple view resolvers in my web app based on spring mvc

Can anyone tell me how do I achieve that.

I want to use both JSP and freemarker in my app. Please suggest some approaches or links or examples..

All help is appreciated.

Adhir

like image 794
Adhir Avatar asked Feb 03 '23 06:02

Adhir


1 Answers

You can add as many view resolvers as you want. You can specify the order in which the view resolvers need to be checked. Spring will take the first view resolver which can successfully resolve the view.

ex: Since you have JSP and freemarker add the view resolvers for both and give the order property 1 for JSP and 2 for freemarker. If your view is /freemarker/hello.ftl then the JSP resoplver will fails since it will not be able to find th file /freemarker/hello.ftl, then the freemarker resolver will handle this view. But if the JSP resolver is able to find the file and resolve it then freemaker resolver will not be used to resolve that view

Refer: Chaining ViewResolvers

like image 165
Arun P Johny Avatar answered Feb 23 '23 04:02

Arun P Johny