{"id":4112,"date":"2020-07-28T17:13:17","date_gmt":"2020-07-28T11:43:17","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=4112"},"modified":"2022-07-19T14:28:22","modified_gmt":"2022-07-19T08:58:22","slug":"what-are-view-resolvers-in-spring","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/what-are-view-resolvers-in-spring\/","title":{"rendered":"What are View Resolvers in Spring?"},"content":{"rendered":"\n<p><a href=\"https:\/\/www.h2kinfosys.com\/blog\/what-is-the-spring-framework-in-java\/\">Spring MVC framework<\/a> provides away with the help of which you can work with the views. It is done with the help of View Resolver, which does not need any specific view technology like JSP, Velocity, etc. The View Resolver maps the view names to the corresponding view. There are various View Resolvers available in Spring, such as InternalResourceViewResolver, XmlViewResolver, etc.<\/p>\n\n\n\n<p>Given below are the various View Resolvers available in Spring MVC:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>AbstractCachingViewResolver: <\/strong>This Resolver provides caching when we extend this.<\/li><li><strong>XmlViewResolver: <\/strong>It accepts a configuration file written in XML with the same DTD as of<a href=\"https:\/\/www.h2kinfosys.com\/blog\/what-are-spring-bean-configurations\/\"> Spring Bean<\/a> factories, and the default configuration file is \/WEB-INF\/views.xml.<\/li><li><strong>ResourceBundleViewResolver: <\/strong>It uses bean definition in a ResourceBundle, which has a specific bundle name, and the default file name is views.properties.<\/li><li><strong>UrlBasedViewResolver: <\/strong>It affects the direct resolution of view names to the URLs.<\/li><li><strong>InternalResourceViewResolver:<\/strong> It is a subclass of UrlBasedViewResolver that supports InternalResourceView (Servlets and JSPs) and subclasses such as JstlView and TilesView. View Class can be specified using setViewClass().<\/li><li><strong>VelocityViewResolver \/ FreeMarkerViewResolver:\u00a0 <\/strong>It is a subclass of UrlBasedViewResolver that supports Velocity View or Free Marker View.<\/li><li><strong>ContentNegotiatingViewResolver:<\/strong> It resolves a view based on the request file name or Accept header.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Spring WEB-MVC Module | spring web services | best online training frame work from H2Kinfosys\" width=\"800\" height=\"450\" src=\"https:\/\/www.youtube.com\/embed\/Gz4OUQelTlo?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example of View Resolver:&nbsp;<\/strong><\/h2>\n\n\n\n<p><strong>Step 1: <\/strong>Add the <a href=\"https:\/\/maven.apache.org\/guides\/introduction\/introduction-to-dependency-mechanism.html\" rel=\"nofollow noopener\" target=\"_blank\">maven dependencies <\/a>in pom.xml file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n&nbsp;&nbsp;xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/maven-v4_0_0.xsd\"&gt;\n&nbsp;&nbsp;&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n&nbsp;&nbsp;&lt;groupId&gt;com.snippets.enterprise&lt;\/groupId&gt;\n&nbsp;&nbsp;&lt;artifactId&gt;springexample&lt;\/artifactId&gt;\n&nbsp;&nbsp;&lt;packaging&gt;war&lt;\/packaging&gt;\n&nbsp;&nbsp;&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n&nbsp;&nbsp;&lt;name&gt;springexample Maven Webapp&lt;\/name&gt;\n&nbsp;&nbsp;&lt;url&gt;http:\/\/maven.apache.org&lt;\/url&gt;\n&nbsp;&nbsp;&lt;dependencies&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;org.springframework&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;spring-webmvc&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;${spring.version}&lt;\/version&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;javax.servlet&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;servlet-api&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;2.5&lt;\/version&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/dependency&gt;&nbsp;\n&nbsp;&nbsp;&lt;\/dependencies&gt;\n&nbsp;&nbsp;&lt;build&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;finalName&gt;springexample&lt;\/finalName&gt;\n&nbsp;&nbsp;&lt;\/build&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;properties&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;spring.version&gt;3.2.3.RELEASE&lt;\/spring.version&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/properties&gt;\n&lt;\/project&gt;\n<\/pre>\n\n\n\n<p><strong>Step 2: <\/strong>Configure the application in web.xml file and mvc-dispatcher-servlet.xml file placed in the \/WEB-INF\/ directory.<\/p>\n\n\n\n<p><strong><em>web.xml<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;web-app xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns=\"http:\/\/java.sun.com\/xml\/ns\/javaee\" xmlns:web=\"http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_2_5.xsd\" xsi:schemaLocation=\"http:\/\/java.sun.com\/xml\/ns\/javaee http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_3_0.xsd\" id=\"WebApp_ID\" version=\"3.0\"&gt; &lt;display-name&gt;Archetype Created Web Application&lt;\/display-name&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-name&gt;mvc-dispatcher&lt;\/servlet-name&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-class&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.springframework.web.servlet.DispatcherServlet\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/servlet-class&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;load-on-startup&gt;1&lt;\/load-on-startup&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/servlet&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-mapping&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-name&gt;mvc-dispatcher&lt;\/servlet-name&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;url-pattern&gt;\/&lt;\/url-pattern&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/servlet-mapping&gt;&nbsp;\n&lt;\/web-app&gt;\n<\/pre>\n\n\n\n<p><strong><em>mvc-dispatcher-servlet.xml<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;beans xmlns=\"https:\/\/www.springframework.org\/schema\/beans\" xmlns:context=\"http:\/\/www.springframework.org\/schema\/context\" xmlns:mvc=\"https:\/\/www.springframework.org\/schema\/mvc\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\" http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd http:\/\/www.springframework.org\/schema\/context http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd https:\/\/www.springframework.org\/schema\/mvc https:\/\/www.springframework.org\/schema\/mvc\/spring-mvc-3.0.xsd\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;context:component-scan base-package=\"com.snippets.enterprise\" \/&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;bean class=\"com.snippets.enterprise.HelloWorldController\" \/&gt;&nbsp;\n&nbsp;&lt;bean&nbsp;\n&lt;\/beans&gt;\n<\/pre>\n\n\n\n<p><strong>Step 3: <\/strong>Create a view named helloWorld.jsp<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;html&gt;\n&lt;body&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Spring 3.2.3 MVC view resolvers example&lt;\/h1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;h3&gt; ${msg}&lt;\/h3&gt;&nbsp;&nbsp;&nbsp;&nbsp;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n\n\n\n<p><strong>Step 4: <\/strong>Create a controller file named HelloWorldController.java<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">package com.snippets.enterprise;&nbsp;\nimport javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;&nbsp;\nimport org.springframework.web.servlet.ModelAndView;\nimport org.springframework.web.servlet.mvc.AbstractController;&nbsp;\npublic class HelloWorldController extends AbstractController{&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;@Override\n&nbsp;&nbsp;&nbsp;&nbsp;protected ModelAndView handleRequestInternal(HttpServletRequest request,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpServletResponse response) throws Exception {&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ModelAndView model = new ModelAndView(\"helloWorld\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;model.addObject(\"msg\", \"hello world!\");&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return model;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n}\n<\/pre>\n\n\n\n<p><strong>Step 5: <\/strong>InternalResourceViewResolver maps the jsp and html files in WebContent\/WEB-INF\/ directory. The view is named as mvc-dispatcher-servlet.xml.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;beans xmlns=\"https:\/\/www.springframework.org\/schema\/beans\" xmlns:context=\"http:\/\/www.springframework.org\/schema\/context\" xmlns:mvc=\"https:\/\/www.springframework.org\/schema\/mvc\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\" http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd http:\/\/www.springframework.org\/schema\/context http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd https:\/\/www.springframework.org\/schema\/mvc https:\/\/www.springframework.org\/schema\/mvc\/spring-mvc-3.0.xsd\"&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;context:component-scan base-package=\"com.snippets.enterprise\" \/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;bean class=\"com.snippets.enterprise.HelloWorldController\" \/&gt;&nbsp;\n&nbsp;&lt;bean &nbsp; class=\"org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping\" \/&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;bean\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class=\"org.springframework.web.servlet.view.InternalResourceViewResolver\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"prefix\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;value&gt;\/WEB-INF\/&lt;\/value&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/property&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"suffix\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;value&gt;.jsp&lt;\/value&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/property&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/bean&gt;&nbsp;\n&lt;\/beans&gt;\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example of&nbsp; XmlViewResolver<\/strong>:<\/h2>\n\n\n\n<p><strong>views.xml<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;beans xmlns=\"https:\/\/www.springframework.org\/schema\/beans\"\n&nbsp;&nbsp;&nbsp;&nbsp;xmlns:xsi=\"https:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n&nbsp;&nbsp;&nbsp;&nbsp;xsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/beans&nbsp;\nhttp:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd\"&gt;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;bean id=\"helloWorld\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class=\"org.springframework.web.servlet.view.JstlView\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"url\" value=\"\/WEB-INF\/helloWorld.jsp\" \/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/bean&gt;&nbsp;\n&lt;\/beans&gt;\n<\/pre>\n\n\n\n<p><strong>mvc-dispatcher-servlet.xml<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;beans xmlns=\"https:\/\/www.springframework.org\/schema\/beans\" xmlns:context=\"http:\/\/www.springframework.org\/schema\/context\" xmlns:mvc=\"https:\/\/www.springframework.org\/schema\/mvc\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\" http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd http:\/\/www.springframework.org\/schema\/context http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd https:\/\/www.springframework.org\/schema\/mvc https:\/\/www.springframework.org\/schema\/mvc\/spring-mvc-3.0.xsd\"&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;context:component-scan base-package=\"com.snippets.enterprise\" \/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;bean class=\"com.snippets.enterprise.HelloWorldController\" \/&gt;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&lt;bean &nbsp; class=\"org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping\" \/&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;bean class=\"org.springframework.web.servlet.view.XmlViewResolver\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"location\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;value&gt;\/WEB-INF\/views.xml&lt;\/value&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/property&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/bean&gt;&nbsp;\n&lt;\/beans&gt;\n\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example of ResourceBundleViewResolver<\/strong>:<\/h2>\n\n\n\n<p><strong>views.properties<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">helloworld.(class)=org.springframework.web.servlet.view.JstlView\nhelloworld.url=\/WEB-INF\/helloworld.jsp<\/pre>\n\n\n\n<p><strong>mvc-dispatcher-servlet.xml<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;beans xmlns=\"https:\/\/www.springframework.org\/schema\/beans\" xmlns:context=\"http:\/\/www.springframework.org\/schema\/context\" xmlns:mvc=\"https:\/\/www.springframework.org\/schema\/mvc\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\" http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd http:\/\/www.springframework.org\/schema\/context http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd https:\/\/www.springframework.org\/schema\/mvc https:\/\/www.springframework.org\/schema\/mvc\/spring-mvc-3.0.xsd\"&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;context:component-scan base-package=\"com.snippets.enterprise\" \/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;bean class=\"com.snippets.enterprise.HelloWorldController\" \/&gt;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&lt;bean &nbsp; class=\"org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping\" \/&gt;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;bean class=\"org.springframework.web.servlet.view.ResourceBundleViewResolver\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"basename\" value=\"views\" \/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/bean&gt;&nbsp;\n&lt;\/beans&gt;\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example of Configure multiple View Resolvers together<\/strong>:<\/h2>\n\n\n\n<p><strong>mvc-dispatcher-servlet.xml<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;beans xmlns=\"https:\/\/www.springframework.org\/schema\/beans\" xmlns:context=\"http:\/\/www.springframework.org\/schema\/context\" xmlns:mvc=\"https:\/\/www.springframework.org\/schema\/mvc\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\" http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd http:\/\/www.springframework.org\/schema\/context http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd https:\/\/www.springframework.org\/schema\/mvc https:\/\/www.springframework.org\/schema\/mvc\/spring-mvc-3.0.xsd\"&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;context:component-scan base-package=\"com.snippets.enterprise\" \/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&lt;bean class=\"com.snippets.enterprise.HelloWorldController\" \/&gt;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&lt;bean &nbsp; class=\"org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping\" \/&gt;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;bean\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class=\"org.springframework.web.servlet.view.InternalResourceViewResolver\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"prefix\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;value&gt;\/WEB-INF\/&lt;\/value&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/property&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"suffix\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;value&gt;.jsp&lt;\/value&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/property&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"order\" value=\"2\" \/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/bean&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;bean class=\"org.springframework.web.servlet.view.XmlViewResolver\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"location\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;value&gt;\/WEB-INF\/views.xml&lt;\/value&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/property&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"order\" value=\"1\" \/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/bean&gt;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;bean class=\"org.springframework.web.servlet.view.ResourceBundleViewResolver\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"basename\" value=\"views\" \/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=\"order\" value=\"0\" \/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/bean&gt;&nbsp;\n&lt;\/beans&gt;\n<\/pre>\n\n\n\n<p>Here, InternalResourceViewResolver has the lowest priority.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring MVC framework provides away with the help of which you can work with the views. It is done with the help of View Resolver, which does not need any specific view technology like JSP, Velocity, etc. The View Resolver maps the view names to the corresponding view. There are various View Resolvers available in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4134,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[1143,1139,1144,1145],"class_list":["post-4112","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorials","tag-resolvers-in-spring","tag-spring-mvc","tag-view-resolver","tag-xmlviewresolver"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=4112"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4112\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/4134"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=4112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=4112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=4112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}