NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
自定义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页面。