spring-boot版本怎么才能允许访问static下的html?

Blade 未结 1 950
fly931
fly931 剑者 2020-12-09 11:00
悬赏:5

一、该问题的重现步骤是什么?


  1. spring-boot版本怎么才能允许访问static下的html?

    一直提示签名认证失败

  2. image.png

  3. yml里已经设置了:


  4. :
      : : always
    
    :
      :
        : /static/**
      :
        : classpath:/static/
    image.png

都不生效

image.png

2. 

3.


二、你期待的结果是什么?实际看到的又是什么?


三、你正在使用的是什么产品,什么版本?在什么操作系统上?


四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。

1条回答
  • @Configuration

    public class BladeConfiguration implements WebMvcConfigurer {


        @Bean

        public SecureRegistry secureRegistry() {

            SecureRegistry secureRegistry = new SecureRegistry();

            secureRegistry.setEnabled(true);

            secureRegistry.excludePathPatterns("/blade-auth/**");

            secureRegistry.excludePathPatterns("/blade-log/**");

            secureRegistry.excludePathPatterns("/blade-system/menu/routes");

            secureRegistry.excludePathPatterns("/blade-system/menu/auth-routes");

            secureRegistry.excludePathPatterns("/blade-system/menu/top-menu");

            secureRegistry.excludePathPatterns("/blade-system/tenant/info");

            secureRegistry.excludePathPatterns("/blade-flow/process/resource-view");

            secureRegistry.excludePathPatterns("/blade-flow/process/diagram-view");

            secureRegistry.excludePathPatterns("/blade-flow/manager/check-upload");

            secureRegistry.excludePathPatterns("/doc.html");

            secureRegistry.excludePathPatterns("/js/**");

            secureRegistry.excludePathPatterns("/webjars/**");

            secureRegistry.excludePathPatterns("/swagger-resources/**");

            secureRegistry.excludePathPatterns("/druid/**");

            secureRegistry.excludePathPatterns("/agilebpm-ui/**");

            return secureRegistry;

        }


        @Bean

        @ConditionalOnProperty(value = "blade.preview.enabled", havingValue = "true")

        public PreviewFilter previewFilter() {

            return new PreviewFilter();

        }


        @Override

        public void addCorsMappings(CorsRegistry registry) {

            registry.addMapping("/**")

                    .allowedOrigins("*")

                    .allowedHeaders("*")

                    .allowedMethods("*")

                    .maxAge(3600)

                    .allowCredentials(true);

        }


        @Override

        public void addResourceHandlers(ResourceHandlerRegistry registry) {

            registry.addResourceHandler("/agilebpm-ui/**").addResourceLocations("classpath:/static/agilebpm-ui/");

        }


        @Override

        public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {

            FastJsonConfig fastJsonConfig = new FastJsonConfig();

            fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteDateUseDateFormat);

            fastJsonConfig.setSerializeFilters(new AbValueFilter());


            FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();

            fastJsonHttpMessageConverter.setDefaultCharset(StandardCharsets.UTF_8);

            fastJsonHttpMessageConverter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_HTML, MediaType.APPLICATION_JSON_UTF8));

            fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig);


            converters.add(0, fastJsonHttpMessageConverter);

        }

    }

    参考这个配置

    0 讨论(0)
提交回复