This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am very new to Spring and am trying to figure out the API. I have the following controller class defined:
When my post method is called, it forwards it on to the confirmSubmission page. Essentially what I want to do is take my submission object and preserve it for the next forward (ex: when a user clicks "confirm" on the next page, I don't want force spring to reconstruct the object, I would like to instead just use the object that was constructed here). Is there any way I can do this? I looked into the BindingResult API and tried a few things that didn't work.
Basically, I want to prevent myself from having to write the code at line 3 in the snippet below:
Joined: Nov 09, 2008
I want to update the thread as I figured out the answer to this question. As it turns out, when you use the RequestMapping annotation, the method that is assigned as the "RequestMapper" can actually take in a parameter that represents the HttpSession. Essentially, the signature of the method would look something like this:
One then can set attributes into the HttpSession which then acts as a cache for a particular user. I honestly feel awkward using the session as a cache. Does anyone have an idea of better caching strategies? One idea that originally crossed my mind from prior experience was to cache these variables in the service layer. However, this presents an issue since spring treats services as singletons: you end up with concurrency issues with this approach. Any input / advice would be greatly appreciated.