when generating the form on the jsp page, I use the form: radiobuttons tag to which I pass a list with parameters.

<form:radiobuttons path="face_id" items="${face_id}" delimiter="<br />" required="true"/> 

How can I make a pre-selected value in the generated list (the checked property in html)?

  • if you can somehow get the value of the value for each value, then you could set a condition like: checked = "$ {this.value == 'exactly'? 'true': 'false'}", but I can't get it to find. - anton lubyanskiy

1 answer 1

solution: set the default value in the java code, before transferring to the jsp page.

 MyDataModel data = new MyDataModel(); Map<Sting, String> face_id = preparedMap.getMap(); data.setFaceId(2); model.addObject("data", data); model.addObject("face_id", face_id); 

Thus, the default value in the list of radiobuttons will be selected with value = "2".