What Is The Component Of Internalresourceviewresolver Inward Boundary Mvc? Interview Question

What Is The Component Of Internalresourceviewresolver Inward Boundary Mvc? Interview Question - Hallo sahabat BEST LEARNING JAVA, Pada Artikel yang anda baca kali ini dengan judul What Is The Component Of Internalresourceviewresolver Inward Boundary Mvc? Interview Question, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan Artikel spring, Artikel spring interview questions, Artikel spring mvc, yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.

Judul : What Is The Component Of Internalresourceviewresolver Inward Boundary Mvc? Interview Question
link : What Is The Component Of Internalresourceviewresolver Inward Boundary Mvc? Interview Question

Baca juga


What Is The Component Of Internalresourceviewresolver Inward Boundary Mvc? Interview Question

Earlier, I induce got explained to yous most how Spring MVC industrial plant internally in addition to how it procedure HTTP asking coming to your spider web application. One of the of import parts of that processing was sentiment resolution, which is handled past times the ViewResolver interface. In this article, you'll larn to a greater extent than most it past times explaining the InternalResourceViewResolver class. The InternalResourceViewResolver is an implementation of ViewResolver inwards Spring MVC framework which resolves logical sentiment advert e.g. "hello" to internal physical resources e.g. Servlet in addition to JSP files e.g. jsp files placed nether WEB-INF folder. It is a subclass of UrlBasedViewResolver, which uses "prefix" in addition to "suffix" to convert a logical sentiment advert returned from Spring controller to map to actual, physical views.


For example, if a user tries to access /home URL in addition to HomeController returns "home" in addition to thus DispatcherServlet volition consult InternalResourceViewResolver in addition to it volition purpose prefix in addition to suffix to notice the actual physical sentiment which is integral to a spider web application.

Like, if prefix is "/WEB-INF/views/" in addition to suffix is ".jsp" in addition to thus "home" volition live resolved to "/WEB-INF/home.jsp" past times InternalResourceViewResolver.

It's every bit good a  best practise to position all JSP files within WEB-INF directory, to enshroud them from straight access (e.g. via a manually entered URL). If nosotros position in addition to thus within WEB-INF directory in addition to thus exclusively controllers volition live able to access them.

Even though it's non mandatory that View tin exclusively live JSP, it tin live JSON also, for event for REST spider web services, only for the sake of simplicity, we'll induce got the event of JSP every bit sentiment inwards this article. If yous are interested inwards sentiment resolution inwards REST spider web services, yous tin induce got a await at REST amongst Spring MasterClass past times Eugen Paraschiv of Baeldung.



How to configure InternalResorveViewResolver inwards Spring MVC

Let's starting fourth dimension start amongst the configuration of sentiment resolvers inwards Spring. You tin configure this ViewResolver either using Java Configuration or XML configuration every bit shown below:


Configuring ViewResolver using XML inwards Spring
Here is unopen to XML snippet to configure a sentiment resolve inwards Spring, yous tin purpose this if yous are working on a Spring projection which is using XML based confirmation:

<bean id="viewResolver"     class="org.springframework.web.servlet.view.InternalResourceViewResolver"     prefix="/WEB-INF/" suffix=".jsp" /> 


Configuring ViewResolver using Java Configuration
From Spring 3.0 yous tin every bit good configure sentiment resolver using Java i.e. without XML. You tin purpose the next code to configure the internal resources sentiment resolver inwards your restrict project:

@Bean   public ViewResolver viewResolver() {     InternalResourceViewResolver irv = new InternalResourceViewResolver();     irv.setPrefix("/WEB-INF/");     irv.setSuffix(".jsp");      return irv;    }

You tin run across that both the XML in addition to Java offers a elementary approach to configure internal resources sentiment resolver inwards Spring. Though, I advise yous purpose Java Configuration which is modern in addition to at i time becoming the measure agency to configure Spring application. If yous are novel to Java Configuration, I advise yous induce got a await at Spring Framework 5: Beginner to Guru, i of the comprehensive in addition to hands-on course of written report to larn modern Spring.

 in addition to how it procedure HTTP asking coming to your spider web application What is the Role of InternalResourceViewResolver inwards Spring MVC? Interview Question




Important points most InteralResourceViewResolver inwards Spring MVC

Here are unopen to of the of import things to know most this useful cast from Spring MVC framework. This volition assistance yous to empathise the menses of your projection better:

1) When chaining ViewResolvers, an InternalResourceViewResolver ever needs to live last, every bit it volition elbow grease to resolve whatsoever sentiment name, no affair whether the underlying resources genuinely exists.

2) The InternalResourceViewResolver is every bit good the default sentiment resolver of DispatcherServlet class, which acts every bit the front end controller inwards Spring MVC framework.

3) By default, InternalResourceViewResolver returns InternalResourceView (i.e. Servlets in addition to JSP) only it tin live configured to homecoming JstlView past times using the viewClass attribute every bit shown below:

/**    * Sets the default setViewClass sentiment cast to requiredViewClass: past times default    * InternalResourceView, or JstlView if the JSTL API is present.    */   public InternalResourceViewResolver() {     Class viewClass = requiredViewClass();     if (viewClass.equals(InternalResourceView.class) && jstlPresent) {       viewClass = JstlView.class;     }     setViewClass(viewClass);   }    /**    * This resolver requires InternalResourceView.    */   @Override   protected Class requiredViewClass() {     return InternalResourceView.class;   }


The payoff of using JstlView is that JSTL tags volition acquire the Locale in addition to whatsoever message source configured inwards Spring. This is peculiarly of import when yous are using JSTL tags for formatting for displaying messages.


JSTL's formatting tags demand a Locale to properly format locale-specific values e.g. currency in addition to dates. It's message tags tin purpose a Spring message source in addition to a Locale to properly select the message to homecoming inwards HTML depending upon Locale.

You tin farther see Spring inwards Action fifth Edition past times Craig Walls for to a greater extent than details on JstlView class. The mass is a precious rock in addition to my favorite to larn Spring inwards detail. It is at i time every bit good updated to embrace Spring 5.0 changes.

 in addition to how it procedure HTTP asking coming to your spider web application What is the Role of InternalResourceViewResolver inwards Spring MVC? Interview Question



4. The InteralResourceViewResolver is i of the several built-in sentiment resolvers provided past times Spring framework, unopen to of the most useful ones are listed below:
  • BeanNameViewResolver - resolves views every bit beans inwards the Spring application context whose ID is the same every bit the sentiment name. For example, if yous induce got a edible bean amongst id = "home" in addition to a controller homecoming a logical sentiment advert every bit "home" in addition to thus this edible bean volition live resolved past times BeanNameViewResolver.
  • FreeMarkerViewResolver - resolver views every bit FreeMarker templates
  • JasperReportsViewResolver - resolves views every bit JasperReports definitions
  • XsltViewResolver - resolves views to live rendered every bit the number of an XSLT transformation. 
Bryan Hassen's has every bit good explained most dissimilar types of sentiment resolvers inwards Spring on his classic course  5 Free Spring Core in addition to Spring Boot Courses for Java Developers


Other Spring related articles yous may similar to explore this blog
  • 23 Spring MVC Interview questions for two to three years experienced (list)
  • How Spring MVC industrial plant internally? (answer)
  • What is the purpose of DispatcherServlet inwards Spring MVC? (answer)
  • How to enable Spring safety inwards Java application? (answer)
  • Does Spring certification assistance inwards Job in addition to Career? (article)
  • How to prepare for Spring Certification? (guide)
  • 3 Best Practices Java Developers Can larn from Spring (article)
  • Difference between @Autowired in addition to @Injection annotations inwards Spring? (answer)
  • 5 Spring in addition to Hibernate online courses for Java developers (list)

Thanks for reading this article. If yous similar this article in addition to thus delight part amongst your friends in addition to colleagues. If yous induce got whatsoever questions or feedback in addition to thus delight drib a comment in addition to I'll test to reply it every bit before long every bit possible.

P.S. - If yous desire to larn how to railroad train RESTful Web Services using Spring Framework, banking concern fit out Eugen Paraschiv's REST amongst Spring course. He has lately launched the certification version of the course, which is amount of exercises in addition to examples to farther cement the existent globe concepts yous volition larn from the course.


Demikianlah Artikel What Is The Component Of Internalresourceviewresolver Inward Boundary Mvc? Interview Question

Sekianlah artikel What Is The Component Of Internalresourceviewresolver Inward Boundary Mvc? Interview Question kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.

Anda sekarang membaca artikel What Is The Component Of Internalresourceviewresolver Inward Boundary Mvc? Interview Question dengan alamat link https://bestlearningjava.blogspot.com/2011/10/what-is-component-of.html

Belum ada Komentar untuk "What Is The Component Of Internalresourceviewresolver Inward Boundary Mvc? Interview Question"

Posting Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel