• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Easy Spring problem!

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm new to spring and was wondering whether someone could help me figure out an easy problem which I cannot.

I have the following method in a controller which I would like to display the data from, on a .jsp. The code is from a tutorial that I've been following however the tutorial doesn't seem to be talking about how the data ends up on the .jsp. I want to display the data in a table on a .jsp which is not how it works at the moment.


 
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you able to provide a link to the tutorial or fully cite the name and author so that we can see the full source to put this into full/proper context?
 
Richard Carrot
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code snippet is from a pluralsight tutorial spring and JDBC, I think his name is Bryan Hansen.
 
Pete Letkeman
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please note, that I'm new to Spring as well, and therefore this could be incorrect.

Presumably, looking at the code the following happens:
1) A get request is made to /rides
2) The method getRides() is called which returns a list of Ride objects
3) Spring finds a template file, named rides.jsp and injects the data into that file then sends that page to the client/web browser.

Step 3 is the "magic" step. As long as you have the JSP file (View) in the correct location Spring will read that file and combine the data from the Model as specified by the Controller.

We don't really have to know how Spring finds the file, as many things are setup by convention over configuration.
There are different template engines out there which can be quickly changed out in Spring and each one handles the data slightly differently.
 
Richard Carrot
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I believe you are correct. I've been able to make some progress. I changed the controller method to this and added the following to a .jsp all seems to be working.



and the .jsp



onto the next thing to solve
 
Pete Letkeman
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great, I'm glad you got it working.

Hopefully it will be a smooth ride from here on out.
 
reply
    Bookmark Topic Watch Topic
  • New Topic