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

Myth丶恋晨 2023-10-15 09:18 210阅读 0赞

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

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

发表评论

表情:
评论列表 (有 0 条评论,210人围观)

还没有评论,来说两句吧...

相关阅读