• 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
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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
 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic