使用 Micronaut 提供静态资源,具有目录层次结构

psy*_*opz 5 java micronaut

鉴于 中的以下配置application.yml,我希望能够从以下两个路径提供文件:

  • http://localhost/static/image.png(来自/root/static/image.png)
  • http://localhost/static/folder/image.png(来自/root/static/folder/image.png)

但是,只有第一条路径有效。第二个返回 200 状态代码,响应正文中包含以下内容:{"message":"Page Not Found","_links":{"self":{"href":"/static/folder/image.png","templated":false}}}

问题似乎是额外的子目录,但我希望**/*映射字段中的 允许子目录。FWIW,如果我请求不存在的资源,我会收到相同的错误。

这是在 Micronaut 2 上。

micronaut:
  application:
    name: api
  router:
    static-resources:
      default:
        paths: file:/root/static
        mapping: /static/**/*
        enabled: true

Run Code Online (Sandbox Code Playgroud)

Rob*_*ill 2

paths应该是一个列表(如复数所示):

  router:
    static-resources:
      default:
        paths: 
          - file:/root/static
        mapping: /static/**/*
        enabled: true
Run Code Online (Sandbox Code Playgroud)