为空"/>
java 用户名不为空
今天主要实现了用validation实现登陆页面,注册页面,修改信息页面用户名,ID,密码不能为空的操作
一 登陆页面的信息不能为空的实现,主要代码:首先进行包的导入
helloWorld.html中
th:errors="${userBean.*}">
HelloWorldCotrolller.java中
// 登陆(将查询的结果返回给result)
@RequestMapping(value = "/init", method = RequestMethod.POST, params = "a")
public String initUpdate(Model model, HttpSession session,
@Valid @ModelAttribute("userBean") UserBean userBean,
BindingResult results) throws SQLException {
int init = helloWorldService.update(userBean);
if (results.hasErrors()) {
log.info("用户名或密码不能为空");
return "helloWorld";
}//主要实现用户名密码不能为空
UserBean result = helloWorldService.searchUser(userBean);
model.addAttribute("userBean", result);//存userBean的值
更多推荐
java 用户名不为空
发布评论