单击登录按钮而不输入用户名或密码时,我收到以下消息 HTTP状态400 - 客户端发送的请求在语法上不正确()。
这意味着它不会进入控制器。
@Controller
public class UserController {
@RequestMapping(value = {"login"}, method = RequestMethod.GET)
public String goLogin(Model model) {
model.addAttribute("user", new User());
return "login";
}
@RequestMapping(value = {"login"}, method = {RequestMethod.POST})
public String doLogin(@ModelAttribute("user") User user,
Model model,
BindingResult bresult) {...}
}
@Entity
@DynamicUpdate
@DynamicInsert
@Table(name = "user")
public class User {
@Id
@GeneratedValue
@Column(name = "user_id")
private int userId = 0;
@Column(name = "user_login")
private String userLogin = "";
@Column(name = "user_pass")
private String userPass = "";
/*setter and getter methods*/
}
<form:form action="login" commandName="user" method="post">
User Name:<form:input path="userLogin" id="userLogin"/><br/>
Password:<form:password path="userPass" id="userPass"/><br/>
<input value="Login" type="submit">
</form:form>