Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what different between InternalResourceViewResolver vs UrlBasedViewResolver

Tags:

I just started using Spring. I came across a lot tutorials. I saw more examples using InternalResourceViewResolver than UrlBasedViewResolver. I looked at the Spring documentation, but I can't figure out the benefit of using one or the other. Can someone provide some explanation?

like image 831
DarkVision Avatar asked Jul 03 '13 16:07

DarkVision


People also ask

What are the different types of view resolver?

Below, we will discuss about three important View Resolver implementations provided by Spring MVC, InternalResourceViewResolver , XmlViewResolver and ResourceBundleViewResolver .

What is the role of InternalResourceViewResolver in Spring MVC?

The InternalResourceViewResolver is used to resolve the provided URI to actual URI. The following example shows how to use the InternalResourceViewResolver using the Spring Web MVC Framework. The InternalResourceViewResolver allows mapping webpages with requests.

Where do the ViewResolver find its view pages?

Go to the src > main > webapp > WEB-INF > right-click > New > Folder and name the folder as views. Then views > right-click > New > JSP File and name your first view.

What is spring boot ViewResolver?

The InternalResourceViewResolver is an implementation of ViewResolver in Spring MVC framework which resolves logical view name e.g. "hello" to internal physical resources e.g. Servlet and JSP files e.g. jsp files placed under WEB-INF folder.


1 Answers

InternalResourceViewResolver is a convenient subclass of UrlBasedViewResolver.

The JavaDoc describes some added properties in InternalResourceViewResolver that might be useful in some situations:

Convenient subclass of UrlBasedViewResolver that supports InternalResourceView (i.e. Servlets and JSPs) and subclasses such as JstlView.

AlwaysInclude: Controls whether either a forward or include is done.

ExposeContextBeansAsAttributes: Allows all beans in context to be available as request attributes, which means they can be referenced from the EL in JSP.

ExposedContextBeanNames: If non-null, specifies the list of beans that will be exposed, as opposed to all of them.

Source from spring forum : Spring Q&A forum

like image 195
AllTooSir Avatar answered Oct 01 '22 07:10

AllTooSir