Hi, on my JSP there is a select box which has some objects pre-populated before the screen is displayed to user for his input. Now what is happending when the user submits the form, it performs server side validations using the Spring Validations and in case some issue is found then redirects to same JSP with the error messages to be displayed on JSP. Now this time the pre-populated objects in my dropdown select box are gone, completely blank. Please tell me what is causing this issue and how to make them permanently available on JSP.
here are my codes:-
I'm setting into model using addAttribute() and on JSP retrieving like this:-
First load of JSP, it is coming and on refresh also it is coming but when a page is submitted or actually processed and comes back then it displays nothing.
Stefan Evans wrote:You have some code here that adds attributes into the model.
This happens on the default render request.
Does it run through this code when processing this page?
Or is that a different render request?
Yes! this is default render request method which gets called when my jsp is loaded for first time. And when user submits the form, another method Action request gets called. In that method, it checks server side validations and if something goes incorrect then it redirects to this same default render request method.
most likely you are not getting in that same handler so your model is not getting populated again, set a breakpoint and see. You could also store it as an @SessionAttributes this way it will stay available for you.