0
我不能讓「記住我」複選框值(400獲得所需的布爾參數「記住」不存在)春季提交表單獲取複選框值不工作
試圖用戶@RequestParam。 (至於輸入電子郵件/密碼)。 如何獲得複選框值而不是400錯誤?
控制器
@RequestMapping(value = "/login", method = RequestMethod.POST) private String doLogin(@RequestParam(value = "inputEmail") String inputEmail, @RequestParam(value = "inputPassword") String inputPassword, @RequestParam(value = "remember") boolean remember, HttpSession session) {
HTML表單
<form class="form-login" method="post" action="/login">
<h2 class="form-login-heading">Please log in</h2>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" name="inputEmail" class="form-control" placeholder="Email address" required
autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" name="inputPassword" class="form-control" placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" name="remember" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block btn-login" type="submit">Log in</button>
</form>
通過在控制器中添加默認值參數進行修正。 @RequestParam(value =「remember」,defaultValue =「false」)布爾值記住 –