我正在使用下面的JSP代码。当我在我的URL中调用/login
进行登录时,它将打开登录页面。但是当我通过URL调用/loginProcess
时,它显示以下错误:
错误:不支持身份验证方法:GET
请在我出错的地方帮助我。
我的JSP代码:
<form:form modelAttribute="user" method="POST" name="loginForm" action="loginProcess" id="loginForm">
<input type="hidden" name="<csrf:token-name/>" value="<csrf:token-value uri="/loginProcess"/>"/>
<div id="login-container" class="fatpad ltMetal shadowBig round top">
<spring:bind path="userName">
<c:if test="${status.error}">
<div id="formError" class="errortip shinyRed round shadowBig thinpad"><span><form:errors path="userName" /></span>
</div>
</c:if>
</spring:bind>
<fieldset>
<ul id="login-form">
<li>
<label for="j_username"><spring:message code="login.UserName" /></label>
<input id="j_username" name="j_username" type="text" class="required" placeholder="Email Address" maxlength="40" <spring:bind path="userName"> <c:if test="${not empty status.error}"> value='<%= (session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY) == null ? userName :session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY)) %>'</c:if> </spring:bind> />
</li>
<li>
<label for="j_password"><spring:message code="login.Password" /></label>
<input id="j_password" name="j_password" type="password" class="required" placeholder="Password" maxlength="30"/>
</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?<csrf:token-name/>=<csrf:token-value uri="/forgotPassword"/>"><spring:message code="login.forgotPassword" /></a>
</div>
</div>
</form:form>
答案 0 :(得分:1)
/ loginProcess不是它的POST操作,你试图使用GET
访问它答案 1 :(得分:0)
将表单方法类型更改为GET.like method =“GET”, 你定义表单方法是post和access get request所以发生这个错误