Spring Boot中的文件夹映射以从URL Spring打开图像

时间:2018-10-24 10:36:27

标签: java spring spring-boot

我想将本地文件夹映射到localhost:8080如何实现此目的。 我正在使用弹簧靴。已将allowall授予了public / pic文件夹。

如何在如下所示的浏览器中打开。

http://localhost:8080/public/pic/default.jpg

上面的链接给出401,并询问用户名和密码。

在弹簧中使用以下代码进行安全性

@Override
    protected void configure (HttpSecurity http) throws Exception {

        http.csrf().disable();
        http.cors().disable();
        http.authorizeRequests()
                .antMatchers("/public/pic/**").permitAll()
                .anyRequest().authenticated()
            .and()
                .httpBasic()
            .and()
                .logout();
        // @formatter:on
    }

本地系统中的/ public / pic文件夹应该在哪里?

1 个答案:

答案 0 :(得分:0)

尝试添加到您的配置中

 @Override
 public int onStartCommand(Intent intent,int flags, int startId){
    return super.onStartCommand(intent,0,START_STICKY);

}