I have a controller method defined as follows -
@RequestMapping(method = RequestMethod.POST, value="/callMe")
public String myMethod(@ModelAttribute MyClass myObj, Model model) {
//Do something
}
How can I make the above controller method to be called even when I do not passed the ModelAttribute myObj.
I do not want to create another controller without it and duplicate the functionality.
Model attribute is already optional. Even if you do not pass model attribute, myObj is created. So checking
will not work.
Try this. create a Boolean in myClass like this
In your jsp which (submits model attribute) add a hidden input like this
then perform this in controller