Tuesday, 22 March 2016

How to get radio button value from html page to controller through Spring MVC + Thymeleaf



<form action="#"
th:action="@{/searchTravelDetails}"
th:object="${searchTravelFormVO}" method="post">
<label th:text="#{global.travel.bus}" >Bus</label>
<input type="radio" name="radiobutton"  value="1"  th:checked="*{bus}"/>
<label th:text="#{global.travel.train}" >Train</label>
<input type="radio"  name="radiobutton" value="0"   th:checked="*{train}" />
</form>


public class SearchTravelFormVO {
   private boolean bus;
   private boolean train;
}


 @RequestMapping(value = "/searchTravelDetails", method = RequestMethod.POST)
public String travelDetailByFilterCriteria(@Valid SearchTravelFormVO searchTravelFormVO,BindingResult bindingResult, Model m,HttpServletRequest request) {

String radiobtnb24=request.getParameter("radiobutton");
}

No comments:

Post a Comment