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

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");

  

原文地址:https://www.cnblogs.com/jifeng/p/10025376.html