springsecurity-自定义403页面

当用户服务某个资源,由于没有相应的权限,我们希望给他返回一个友好的页面。步骤如下:

  1.在配置类的configure(HttpSecurity http)加上下面的一条语句即可,表示当没有权限时,跳转到/unAuth.html,当然了,在static目录或者其他静态目录下得有unAuth.html页面

    protected void configure(HttpSecurity http) throws Exception {
        http.exceptionHandling().accessDeniedPage("/unAuth.html");
原文地址:https://www.cnblogs.com/ibcdwx/p/14369575.html