当我将我的应用程序部署到 Google 云平台时,未检测到相对文件路径
Relative File Paths not getting detected when I deploy my app to Google Cloud platform
本地一切正常,但是一旦我将我的应用程序部署到 App Engine。 google 云
未获取相对文件路径
根据 Where to put your static files,
You must put your static served files within your app's webapp directory. You can use folders, but remember that all file paths and URIs are relative to the webapp directory.
After you choose a location for the static files, you must define their location in the appengine-web.xml file, using the element.
如何配置的示例是:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<runtime>java8</runtime>
<static-files>
<include path="/**.html" >
</include>
</static-files>
</appengine-web-app>
此外,在文档中:[直接从您的应用提供文件]
(https://cloud.google.com/appengine/docs/standard/java11/serving-static-files#serving_from_your_application),它提到:
To serve static files for Java 11 in the standard environment, you define the handlers in your app.yaml file using either the static_dir or static_files elements.
例如,以下行指示浏览器加载 main.css
文件:
<link type="text/css" rel="stylesheet" href="/static/css/main.css">
./public
目录在项目的 app.yaml
文件的 static_dir
元素中定义:
handlers:
- url: /favicon\.ico
static_files: favicon.ico
- url: /static
static_dir: public
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
本地一切正常,但是一旦我将我的应用程序部署到 App Engine。 google 云
未获取相对文件路径根据 Where to put your static files,
You must put your static served files within your app's webapp directory. You can use folders, but remember that all file paths and URIs are relative to the webapp directory.
After you choose a location for the static files, you must define their location in the appengine-web.xml file, using the element.
如何配置的示例是:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<runtime>java8</runtime>
<static-files>
<include path="/**.html" >
</include>
</static-files>
</appengine-web-app>
此外,在文档中:[直接从您的应用提供文件] (https://cloud.google.com/appengine/docs/standard/java11/serving-static-files#serving_from_your_application),它提到:
To serve static files for Java 11 in the standard environment, you define the handlers in your app.yaml file using either the static_dir or static_files elements.
例如,以下行指示浏览器加载 main.css
文件:
<link type="text/css" rel="stylesheet" href="/static/css/main.css">
./public
目录在项目的 app.yaml
文件的 static_dir
元素中定义:
handlers:
- url: /favicon\.ico
static_files: favicon.ico
- url: /static
static_dir: public
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto