Java 当登录失败时,在spring中保留用户名
我有一个包含以下代码的jsp文件Java 当登录失败时,在spring中保留用户名,java,spring,jsp,Java,Spring,Jsp,我有一个包含以下代码的jsp文件 <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-contai
<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>
当登录失败时,我需要保留用户名
<form:form>
<form:input path="username" />
</form:form>
但是我不知道在哪里使用上面的代码,请帮我解决这个问题。我们的login.jsp中有这个标签,它似乎可以正常工作:
<input id="j_username"
type="text"
name="j_username"
value="${sessionScope.SPRING_SECURITY_LAST_USERNAME}"
placeholder="Username"
class="form-control no-border">
$sessionScope.SPRING\u SECURITY\u LAST\u用户名似乎起到了作用