問題是如果未選中複選框,請求無法在springMVC控制器中找到正確的映射函數。因爲它看起來好像只發送真值,如果它被選中,但如果未檢查,則不發送錯誤值。如何在spring mvc控制器中接收html複選框的值
<form action="editCustomer" method="post">
<input type="checkbox" name="checkboxName"/>
</form>
@RequestMapping(value = "/editCustomer" , method = RequestMethod. POST)
public void editCustomer(@RequestParam("checkboxName")String[] checkboxValue)
{
if(checkboxValue[0])
{
System.out.println("checkbox is checked");
}
else
{
System.out.println("checkbox is not checked");
}
}