'HTTP Status 500 – Internal Server Error (Spring MVC + Hibernate)

I haven't been able to solve this problem for an hour now. Throws this error

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'login' available as request attribute

I used to solve this problem by simply adding the model to the method

Here is my code

AuthorizationController.java

@Controller
public class AuthorizationController {

@Autowired
private AuthorizationService authorizationService;

@RequestMapping("/")
public String firstView(){
    return "first-view";
}

@RequestMapping("/authorization")
public String authorization(Model model){
    model.addAttribute("authorization",new User());
    return "authorization";
}

@RequestMapping("/login")
public String login(Model model){
    model.addAttribute("login",new User());
    return "login";
}

@RequestMapping("/loginSuccess")
public String loginSuccess(@Valid @ModelAttribute("user") User user, BindingResult result,Model model){

    if(result.hasErrors()){
        return "login";
    }

    if(authorizationService.getTypeOfAccount(user.getLogin()).equals("Reader")){
        return "reader/main-menu";
    }
    else{
        return "librarian/main-menu";
    }
}

@RequestMapping("/authorizationSuccess")
public String authorizationSuccess(@Valid @ModelAttribute("user") User user, BindingResult result){

    if(result.hasErrors()){
        return "authorization";
    }
    authorizationService.authorization(user);
    return "/";
}

}

AuthorizationDAOImpl.java

@Repository
public class AuthorizationDAOImpls implements AuthorizationDAO{

@Autowired
private SessionFactory factory;

@Override
public void authorization(User user) {
    Session session = factory.getCurrentSession();
    session.save(user);
}

@Override
public String getTypeOfAccount(String login) {

    Session session = factory.getCurrentSession();
    String type = session.createQuery("SELECT u.type FROM User u WHERE login LIKE " + login).getQueryString();
    return type;

}
}

login.jsp

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>

<html>

<head>
    <%@ page language="java" pageEncoding="UTF-8"%>
</head>

<body>

<h3 align="center"> Введите свои данные для входа! </h3>

<form:form action="loginSuccess" modelAttribute="login">

    Enter login <br>
    <form:input path="login"/>
    <br><br>
    Enter password <br>
    <form:input path="password"/>
    <br><br>
    <input type="submit" value="Log in">

</form:form>


</body>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source