助力软件开发企业降本增效 PHP / java源码系统,只需一次付费,代码终身使用! 广告
自定义403页面步骤如下: **1. 配置类** ```java @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { ... //自定义403页面 http.exceptionHandling().accessDeniedPage("/unauth"); } } ``` **2. controller层** ```java @Controller public class IndexController { @RequestMapping("/unauth") public String unauth() { return "unauth"; } } ``` **3. 测试** 当用户访问不具备权限的资源时就会显示自定义的403页面。