How Spring controller layer authentication is enabled?

1. Sample Code

	@PostMapping("/adduser")
	public String addUser(@Valid User user,BindingResult bindingResult) {//第一步和第二步
		 
		if(bindingResult.hasErrors()) {//第三步
			return "add-user";
		}
		
		userDao.getUsers().add(user);
		
		return "redirect:/allUser";
	}

  The first step in the introduction of notes @Valid   right of the need to pass a POJO class

       The second step, binding authentication information BindingResult bindingResult

    The third step is to determine whether an error has occurred, prompt message is then returned to add a user interface

Guess you like

Origin www.cnblogs.com/max-hou/p/11104768.html