所以我正在尝试使用hibernate创建spring身份验证。我已经检查了可能在互联网上提供的关于这个问题的所有教程,但我似乎遗漏了一些东西,因为当我在表单中按下提交按钮时,没有执行身份验证而我没有被重定向我应该被重定向的地方......
这是我的安全配置:
<bean id='userDetailsService' class='fi.social.web.services.UserDetailsServiceImpl'></bean>
<security:http auto-config="true">
<security:form-login login-page="/" default-target-url="/welcome"
authentication-failure-url="/loginfailed" />
</security:http>
<bean id='daoAuthenticationProvider' class='org.springframework.security.authentication.dao.DaoAuthenticationProvider'>
<property name='userDetailsService' ref='userDetailsService' />
</bean>
<bean id='authenticationManager' class='org.springframework.security.authentication.ProviderManager'>
<property name='providers'>
<list>
<ref local='daoAuthenticationProvider' />
</list>
</property>
</bean>
<security:authentication-manager>
<security:authentication-provider user-service-ref='userDetailsService'>
<security:password-encoder hash='plaintext' />
</security:authentication-provider>
</security:authentication-manager>
和我的JSP页面:
<form method="post" name="loginForm" action="<c:url value='j_spring_security_check' />">
<table style="position:absolute; right:15px;">
<tr>
<td><input type="text" name="j_username" placeholder="<fmt:message key="user.usernameOrEmail"/>"/></td>
<td><input type="password" name="j_password" placeholder="<fmt:message key="user.password"/>"/></td>
</tr>
<tr>
<td colspan="2" style="color: white; text-align:right">
<input type="checkbox" name="remember" /><fmt:message key="user.remember" />
<input type="submit" name="submit" style="margin:0px 0px 0px 15px; display:inline;" value="<fmt:message key="user.logIn"/>" />
</td>
</tr>
</table>
</form>
仍然,出于某种原因,当我提交表格时,我会去
http://127.0.0.1:8080/social/j_spring_security_check;jsessionid=C00D6F0CA27E3B359A9B04B8FADDD87F
即使春天应该知道我的表格在那里,它应该处理参数...... 那么我做错了什么?
答案 0 :(得分:0)
您是否尝试使用<form method="post" name="loginForm" action='#{request.contextPath}/j_spring_security_check'>
你的配置也有一件奇怪的事情(但从你所说的那不是现在的问题):
这是你宣布两个authentication managers
:
<security:authentication-manager>,
<bean id='authenticationManager' class='org.springframework.security.authentication.ProviderManager'>
尝试删除
<security:authentication-manager>
<security:authentication-provider user-service-ref='userDetailsService'>
<security:password-encoder hash='plaintext' />
</security:authentication-provider>
</security:authentication-manager>