Wednesday, 7 May 2014

When you are using @SessionAttributes annotaion in your controller and using the same Model Attribute in multiple Request mapping methods in the same controller ; you willrun into issues if you try working in multiple tabs.

What happens is, because Session Attributes stored in SessionAttributeStore are identified by just their name, and when ever a new Object is added with same name to the store the previous one gets overridden.

Very Common scenario could be a simple create and Edit of a page where you have opened a Create new page and before hitting submit you opened an Edit page for some other record in another Tab. This Causes the Edit record Model Attribute overriding the Create new ModelAttribute in the Session Resulting is Error.

In-order to resolve this issue you will have to teach Spring not to store / retrieve the Objects from Session Attribute Store by name but by a unique identification String.

In your  *context.xml you need to define the following beans