You need to pass this variable as a parameter from your request to send / receive to the controller and access it in the controller, for example:
@RequestMapping(...) public String getCountySelected(@RequestParam(value = "UR_PARAM_NAME") String param){ ... code goes here }
EDIT: If you are not using ajax and want to submit an additional parameter while submitting the form:
Add a variable to the form domain class with the @Transient annotation @Transient that spring does not look up the corresponding element in the database table.
eg.
@Transient private String countrySelection;
And then add the hidden form variable in jsp, for example:
<form:hidden path="countrySelection"/>
And then set $("#countrySelection").value(countrySelection); using your jquery.
In the controller, you can access this line using the getter method of objects.
source share