java - Retaining username in spring, when login fails -


i have jsp file below code

    <form:form modelattribute="user" method="post" name="loginform" action="loginprocess" id="loginform" autocomplete="off">         <input type='hidden' name='remember-me' value="true" />         <div id="login-container">              <spring:bind path="username">                 <c:if test="${status.error}">                     <div id="formerror" <span><form:errors path="username" /></span></div>                 </c:if>             </spring:bind>              <fieldset>                 <ul id="login-form">                     <li>                         <label for="username"><spring:message code="login.username" /></label>                         <input id="username" name="username" type="text"  <spring:bind path="username"> <c:if test="${not empty status.error}"> value='<%= (session.getattribute(usernamepasswordauthenticationfilter.spring_security_form_password_key) == null ? username :session.getattribute(usernamepasswordauthenticationfilter.spring_security_form_password_key)) %>'</c:if> </spring:bind> />                     </li>                     <li>                         <label for="password"><spring:message code="login.password" /></label>                         <input id="password" name="password" type="password" />                     </li>                     <li>                         <div class="bucontainer">                             <a class="buorange large" id="submit" href="#" onclick="validateform()"><spring:message code="login.login" /></a>                         </div>                     </li>                 </ul>             </fieldset>             <div class="bucontainer">                 <a id="forgot-link" href="forgotpassword"><spring:message code="login.forgotpassword" /></a>                 </div>           </div>     </form:form> 

here when login fails need retain username.i tried

<form:form> <form:input path="username" /> </form:form> 

but dont know use above code, please me on this.

we have tag in our login.jsp, seems work ok:

<input id="j_username"        type="text"        name="j_username"        value="${sessionscope.spring_security_last_username}"        placeholder="username"        class="form-control no-border"> 

the $sessionscope.spring_security_last_username seems trick.


Comments