I joined a project which uses spring framework and all the calls are made by ajax requests and the redirection after success is defined in the view itself and passed to the ajax JS function through a hidden input (so the return ModelAndView at the end of every function in the controller doesn’t have any effect). I feel it messes up the code somehow Am I right? Still I think this was done because they wanted to get the benefits of having restful app with CRUD mapped to post,get,put,delete but eventually they lost the ability to redirect from the controller itself.
- I want to know if there was other pattern to hold all that.
- I also want to know the pros and cons of the previous way Vs using only GET and POST which easily allows redirection from the controller.
Well the pattern which i generally use and recommend is the following:
the data from backend ( user sees a loader)
from the backend ( provides more control over redirection)
Advantages with this approach: