我是Spring Security的新手。使用Spring 4.3和Spring Security 5.0。一切 运行。登录页面也来了。如果您提供了错误的密码,它会告诉您的登录尝试不成功,请再试一次。精确但正确的密码会使其提出异常
我的Spring_Security。 XML是
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="1234" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
我的Web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-security.xml,
/WEB-INF/spring/appServlet/hibernate.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/appServlet/servlet-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
我的控制器类
@RequestMapping(value="/admin", method=RequestMethod.GET)
public String privateHome() {
return "privatePage";
}
When Run the Code /admin page its default run log in page .Everything Fine
。一旦得到正确的证书我得到了没有映射的密码编码器 id“null”
答案 0 :(得分:0)
您可以查找此问题的答案:Spring security : migrating 4.0 to 5.0 - Error -There is no PasswordEncoder mapped for the id “null”
但是,对于 Spring Security 5,正确的定义是:
<bean id ="passwordEncoder" class = "org.springframework.security.crypto.password.NoOpPasswordEncoder" factory-method = "getInstance" />