【问题标题】:Configuring static files (CSS) in Java11 Appengine project在 Java 11 App Engine 项目中配置静态文件 (CSS)
【发布时间】:2021-08-12 13:21:37
【问题描述】:

我正在尝试将我的 Java Servlet 项目移植到 App Engine。我无法正确部署我的 CSS 文件。下面是我的配置和我的 app.yaml 配置。我做错了什么?

【问题讨论】:

标签: java google-app-engine google-cloud-platform


【解决方案1】:

您需要更改 webapp 的处理程序 url。它必须是这样的:

handlers:
  - url: /webapp/(.*\.(gif|png|jpg|js|css|json))$
    static_dir: webapp\1

它对位于嵌套文件夹中的文件使用正则表达式

【讨论】:

    【解决方案2】:
    handlers:
    # All URLs beginning with /stylesheets are treated as paths to
    # static files in the stylesheets/ directory.
    - url: /stylesheets
      static_dir: stylesheets
      # ...
    

    选自documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-04
      • 2018-08-05
      • 2015-03-02
      • 1970-01-01
      • 2021-11-27
      • 2011-07-18
      • 2013-09-23
      相关资源
      最近更新 更多