Java 无法使用BCryptPasswordEncoder登录
我正在使用spring安全加密,但无法登录。 我的spring-security.xml是Java 无法使用BCryptPasswordEncoder登录,java,spring,spring-mvc,spring-security,Java,Spring,Spring Mvc,Spring Security,我正在使用spring安全加密,但无法登录。 我的spring-security.xml是 <?xml version="1.0" encoding="UTF-8"?> < beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.spring
<?xml version="1.0" encoding="UTF-8"?>
< beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<security:global-method-security secured-annotations="enabled" />
<security:http auto-config="true" >
<security:intercept-url pattern="/index*" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/emppreviewshow" access="ROLE_EMPLOYEE"/>
<security:access-denied-handler error-page="/login"/>
<security:form-login login-page="/login" default-target-url="/index"
authentication-failure-url="/fail2login"
username-parameter="username"
password-parameter="password" />
<security:logout logout-success-url="/logout" />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service data-source-ref="dataSource"
users-by-username-query=
"select username,password, enabled from USER_MASTER where username=?"
authorities-by-username-query=
"select username,USER_ROLE from USER_ROLE where username =? " />
<security:password-encoder ref="passwordEncoder"/>
</security:authentication-provider>
</security:authentication-manager>
<bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" >
<constructor-arg name="strength" value="12" />
</bean>
我的jsp表单是
<form name='loginForm' class="form-signin" action="<c:url value='j_spring_security_check' />" method="post">
<h2 class="form-signin-heading" style="padding-left:120px;">Login</h2>
<input type="text" class="form-control" ng-model = "username" name="username" placeholder="Email Address" required autofocus />
<br>
<input type="password" class="form-control" ng-model = "password" name="j_password" placeholder="Password" required/>
<br>
<input name="submit" type="submit"
value="submit" />
<a href="" style="padding-left:100px;">Forgot Password</a>
<input type="hidden" name="${_csrf.parameterName}"
value="${_csrf.token}" />
</form>
登录
但我无法登录。登录时我甚至没有遇到异常。是否有任何设置需要执行更多操作,或者配置中是否存在任何错误。调试日志是什么样子的?您是否尝试将调试点添加到BCryptPasswordEncoder?将spring security log level设置为debug并再次尝试使其在没有bcrypt编码器的情况下工作?是的,没有加密,它工作正常。生成并存储在数据库中,但我必须保留调试点,因为检索和检查将由spring-security.xml负责