require String parameter "password" is not parent
阿新 • • 發佈:2019-02-03
public String login(@RequestParam("loginname") String loginname, @RequestParam("password") String password, Model model){
logger.info("登陸名:"+loginname + "密碼"+password);
// 到集合中查詢使用者是否存在,此處用來模擬資料庫驗證
for (User user: userList){
if (user.getUserName().equals(loginname)
&& user.getPassword().equals(password)){
model.addAttribute("user",user);
return "welcome";
}
}
return "loginForm";
}
login.jsp檔案,id的loginame寫錯 loginname
<h3>登陸頁面</h3>
<br>
<form action="login" method="post"/>
<table>
<tr>
<td><label>登陸名:</label></td>
<td><input type="text" id="loginname" name="loginname"></td>
</tr>
<tr>
<td><label>密碼:</label></td>
<td ><input type="password" id="password" name="password"></td>
</tr>
<tr>
<td><input id="submit" type="submit" value="登陸"></td>
</tr>
</table>
</body>
</html>