springsecurity-自定义403页面

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

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

    protected void configure(HttpSecurity http) throws Exception {
        http.exceptionHandling().accessDeniedPage("/unAuth.html");

 

posted @ 2021-02-03 20:30  爱编程DE文兄  阅读(196)  评论(0编辑  收藏  举报