首页  :: 新随笔  :: 管理

springboot shiro 项目前端页面访问问题总结

Posted on 2018-11-27 11:27  季枫  阅读(4315)  评论(0编辑  收藏  举报

1、springboot前端页面默认需要放到指定的目录下才能访问

在/src/main/resource目录下的:

/static
/public
/resources
/META-INF/resources

  

2、自定义目录映射

  例如:将/src/main/resource/templates/** 作为静态目录

  

@Configuration
public class WebFileConfigurer extends WebMvcConfigurerAdapter {
@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /**
         * 虚拟路径映射
         */
        registry.addResourceHandler("/video/**").addResourceLocations("classpath:/video/");
        registry.addResourceHandler("/*.html").addResourceLocations("classpath:/templates/");
        super.addResourceHandlers(registry);
    }
}

3、集成shiro 则需要开放权限

//开放匿名访问
filterChainDefinitionMap.put("/index.html*", "anon");
//登录页面地址
shiroFilterFactoryBean.setLoginUrl("/index.html#/login");
// 登录成功后要跳转的链接
shiroFilterFactoryBean.setSuccessUrl("/index.html");

  

 

智读 | 成都会领科技有限公司官网 | 智读App下载 | 每天听本书的博客 | |