我有一个带有以下代码的
的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-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>
这里登录失败时我需要保留username.I try
<form:form>
<form:input path="username" />
</form:form>
但我不知道上面的代码在哪里使用,请帮我解决这个问题。
答案 0 :(得分:1)
我们在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_SECURITY_LAST_USERNAME
似乎可以解决问题。