开发者

Spring mvc and different required fields depending on action

i have a form with 2 buttons let say A & B.

The required fields are depending on the button pressed.

Im using actually a DataBinder allowing me to specify requi开发者_StackOverflow社区redFields but for all actions. How can i customize the required fields that will be depending on the button pressed ?

Thanks in advance


If you use <input type="submit" name="button1" value="Click me!" /> you can check for that button1 value in your form and then use different validation rules within your validator. You just have to extend your binding model according to these button names and to give your two buttons different names. Note that this doesn't work with <button type="submit"> in most IE versions and therefor input[type=submit] is the better choice here :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜