I can able to invoke the method when submit the button.But I need to invoke method when drop down value selected from drop down list in SpringBoot.
I tried using below but didn't worked.
Please find the sample code as shown below:
<select th:field="*{country}" xmlns:th="th">
<option value="">Select</option>
<option value="first">1</option>
<option value="second">2</option>
<option value="third">3</option>
</select>
Java code:
@Controller
public class Countries() {
@GetMapping(value = "/")
public String menu(ModelMap model) {
model.addAttribute("createMenu", new Country());
return "menu";
}
@RequestMapping("/first")
public List<Object> country(){
System.out.println("first");
return null;
}
}
When selected dropdown value then invoke method to get list of states.Can anyone please help me on this.