i have a register view that takes @RequestParamsand sets the fields in a form. There are 2 fields name and phone. If I call the view as /register?name=myname&phone=mynumber, it sets the fields to the correct values, but i have to click ‘Submit’ button to submit the form. The form submit action happens in the same view. what should i do so that when i have called the view with all the required parameters, it will automatically submit and make an entry in the DB?
i have a register view that takes @RequestParams and sets the fields in a
Share
The problem you’re facing is, when you request
/register?name=myname&phone=mynumber, the parameters are used to set the fields, but the@ModelAttributes in your controller are being initialised to empty objects. Only when you click the ‘Submit’ button does the values bind to the specific fields in the@ModelAttributes. Then you (apparently in the same controller) process the form, (probably validate it) and update your records (DB).