Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

[Spring MVC]connection between controller and view

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I dont understand where is the connection between the controller and view. For instance here is good and short example
http://maestric.com/doc/java/spring/mvc
But, I cant see the connection between
jsp/carList.jsp - list_cars.html

I see the list_cars.html handled by CarListController and what next, how can we arrive at the jsp/carList.jsp ?

Thanks in advance.

 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Csaba Szegedi wrote:Hello,

I dont understand where is the connection between the controller and view. For instance here is good and short example
http://maestric.com/doc/java/spring/mvc
But, I cant see the connection between
jsp/carList.jsp - list_cars.html

I see the list_cars.html handled by CarListController and what next, how can we arrive at the jsp/carList.jsp ?

Thanks in advance.



The MVC Architecture is

a request comes in. The DispatcherServlet gets it and delegates to a MappingHandler that looks at the URL and determines the Controller and its method to call, it calls it. The Controller returns something or void. This then goes back to the DispatcherServlet that delegates to ViewResolvers to resolve the view to display.

So in your case, the controller returns probably "carList" and in the Spring configuration there is an InternalResourceViewResolver that adds a string to the front of "carList" hence, "jsp/" and appends ".jsp" to the end of "carList.

Hope that helps

Mark
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic