• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

SpringMVC - Unable to pass model objects between controllers

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am new to SpringMVC using annotations. Learning the flow, but stuck with a situation where I need to pass mode objects between two controllers. For eg, I have a Login Controller and Customer Controller, If login is success it will redirect to the Customer Controller where the customer details are displayed. When logged in, I need to get the login model objects (which contain login username & password) inorder to get the Customer objects. I tried using @ModelAttribute("login"), but not working.
Posted code snippets below:

LoginController


CustomerDetailsController


But here the login attribute is empty so that I cannot query the Customer object using the id and password
Please Help..! Thanks in Advance..
 
Ranch Hand
Posts: 123
Firefox Browser Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try using @SessionAttributes.

- k


-----------------------------------------------------------------------------------------------
[SpringSource Certified Spring Professional (Spring Certification) – Practice Tests]
 
Shihu Salam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the solution..!!! Spring 3.1 introduces a new feature called 'RedirectAttributes' where we can set our object in one controller (POST) and retrieved in the other controller (GET), which will solve the issue.
Thanks for the reply..

LoginController


CustomerDetailsController
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic