Я написал простую форму входа / регистрации и просто пытался отправить данные с одной страницы на другую с помощью атрибута модели. есть мои формы и контроллер
<form:form id='login-form' action="/welcomeLogin" method='post' modelAttribute="userLogin">
<form:input type="text" path="username" placeholder="Username"/>
<form:input type="password" path="password" placeholder="Password"/>
<form:button type='submit' name="loginParam">Login</form:button>
<label for='form-switch'><span>Register</span></label>
</form:form>
<form:form id='register-form' action="/welcomeRegister" method='post' modelAttribute="newUserRegister">
<form:input type="text" path="regUsername" placeholder="Username" />
<form:input type="email" path="regEmail" placeholder="Email" />
<form:input type="password" path="regPassword" placeholder="Password" />
<form:input type="password" path="regRepPassword" placeholder="Re Password" />
<form:input type="text" path="regFirstname" placeholder="Firstname" />
<form:input type="text" path="regLastname" placeholder="Lastname" />
<form:input type="text" path="regPersNumber" placeholder="Personal number" />
<form:select path="regBirthDay">
<jsp:useBean id="dayList" scope="request" type="java.util.List"/>
<form:options items="${dayList}"/>
</form:select>
<form:radiobutton type="radio" path="regGender" name="gender" value="male"/> Male
<form:radiobutton type="radio" path="regGender" name="gender" value="female"/> Female<br>
<form:button type='submit' name="registerParam">Register</form:button>
<label for='form-switch'>Already Member ? Sign In Now..</label>
</form:form>
и контроллер:
@RequestMapping(method = RequestMethod.GET, value = "/")
public String getRegisterLogin(@RequestParam(required=false, value="loginParam") String loginParam,
@RequestParam(required=false, value="registerParam") String regParam,
Model model){
if (loginParam!=null){
model.addAttribute("userLogin", new userLogin());
} else if (regParam!=null){
model.addAttribute("newUserRegister", new userRegister());
}
return "index";
}
У меня ошибка:
Neither BindingResult nor plain target object for bean name 'userLogin' available as request attribute
Может кто-нибудь помочь мне исправить это?