nested exception is java.lang.IllegalArgumentException: errorPage must begin with ‘/‘

1、错误信息

在使用springSecurity权限控制框架的时候报错:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Unsatisfied dependency expressed through method 'setFilterChains' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityFilterChain' defined in class path resource [com/txc/securitydemo1/config/SecurityConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.SecurityFilterChain]: Factory method 'securityFilterChain' threw exception; nested exception is java.lang.IllegalArgumentException: errorPage must begin with '/'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:774) ~[spring-beans-5.3.29.jar:5.3.29]
    at 

2、错误分析及解决方案

本质就是提示页面的前缀必须包含/,如下配置,路径必须包括/符号-/login.html

 http.loginPage("/login.html")
                .loginProcessingUrl("/login")//登录接口
                .usernameParameter("username")
                .passwordParameter("password")
                .defaultSuccessUrl("/test")
                // 放行登录地址(访问登录地址无需已登录状态)
                .permitAll()
                .and().csrf();

你可能感兴趣的:(Java开发常见BUG解决方案,java,pycharm,开发语言)