java - Trying to make a login with Spring -
so making login our project. problem have null in our parameters , not actual value entered. know why?
controller code:
@requestmapping(value = "/user/login",method = requestmethod.post) public string login(@modelattribute("user") user user) { //random code here homecoming "redirect:/general/index.html"; }
view:
<form:form id="header_login_form" method="post" modelattribute="user" action="/projectteamf-1.0/user/login.html"> <input path="username"class="input" placeholder="email" /> <input path="password" class="input" placeholder="password" /> <label class="checkbox"> <input type="checkbox"> aangemeld blijven</label> <button type="submit" class="btn">aanmelden</button> </form:form>
you need utilize tag <form:input>
instead of <input>
in order spring bind user
modelattribute. , replace modelattribute
commandname
:
<form:form id="header_login_form" method="post" commandname="user" action="/projectteamf-1.0/user/login.html"> <form:input path="username"class="input" placeholder="email" /> <form:input path="password" class="input" placeholder="password" /> <label class="checkbox"> <input type="checkbox"> aangemeld blijven</label> <button type="submit" class="btn">aanmelden</button> </form:form>
java html spring authentication login
No comments:
Post a Comment