2)、如何定制错误的json数据;
修改用户登录,模拟异常
@PostMapping("/user/login")
public String login(String username, String password, HttpServletRequest httpServletRequest) throws UserNotExistException {
System.out.println("user:"+username);
System.out.println("pwd:"+password);
if("admin".equals(username)){
throw new UserNotExistException();
}
}
UserNotExistException
public class UserNotExistException extends Exception{
public UserNotExistException() {
super(