在GAE java标准环境中配置路由 [英] Configure routing in GAE java standard environment

查看:165
本文介绍了在GAE java标准环境中配置路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



该应用在本地工作正常,但部署时,我得到了一个刷新或尝试键入所需页面的URL时出现404错误。



我明白,我必须定义一个路由回退,如角度文档,以便将每个未知请求重定向到我的索引.html。



据我了解,来自许多stackoverflow GAE appengine python的问题,解决方案包括配置app.yaml文件。



好的,但是怎么样?在应用引擎标准环境中,app.yaml文件是在分段文件夹中自动生成的,如下所示,但是当我使用eclipse的Google插件部署时,所有事情都会发生在引擎盖下,我无法访问。

 运行时:java7 
inbound_services:
- 预热
derived_file_type:
- java_precompiled
threadsafe:True
auto_id_policy:default
api_version:'1.0'
处理程序:
- url:(/.*/)
static_files:__static__\1index。 html
上传:__NOT_USED__
require_matching_file:True
登录:可选
安全:可选
- url:(/)
static_files:__static__\1index。 html
上传:__NOT_USED__
require_matching_file:True
登录:可选
安全:可选
- url:(/.*)
static_files:__static__\ 1
上传:__NOT_USED__
require_matching_file:True
登录:可选
安全:可选
- url:/.*
脚本:未使用
登录:可选
秒ure:可选

有人可以告诉我有没有办法在部署之前编辑app.yaml文件在appengine java标准环境中。
类似的问题最近发布,但目前没有任何回应。

解决方案

我认为您是从浏览器端发生的角色路由,从服务器端URL路由(由 web.xml 描述)导致混淆。



我的猜测是,您的 web.xml 缺少欢迎文件来加载的index.html 。例如,这里是一个简单的 web.xml ,应该这样做:

 <?xml version =1.0encoding =utf-8?> 
< web-app xmlns =http://java.sun.com/xml/ns/javaeeversion =2.5>
< welcome-file-list>
< welcome-file> index.html< / welcome-file>
< / welcome-file-list>
< / web-app>


I have a GAE application in java standard environment for the backend and angular 4.0 for the frontend.

The app works fine locally, but when deployed, I get a 404 error when refreshing or when trying to type the url of the desired page.

I understand that I have got to define a routing fallback as described in the angular documentation in order to redirect every unknown request to my index.html.

As I understand it from many stackoverflow GAE appengine python questions, the solution consists of configuring the app.yaml file.

Ok, but how? In the app engine standard environment, the app.yaml file is auto-generated in the staging folder as follow, but everything happens under the hood when I deploy with the google plugin for eclipse and I have no access to it.

runtime: java7
inbound_services:
- warmup
derived_file_type:
- java_precompiled
threadsafe: True
auto_id_policy: default
api_version: '1.0'
handlers:
- url: (/.*/)
static_files: __static__\1index.html
upload: __NOT_USED__
require_matching_file: True
login: optional
secure: optional
- url: (/)
static_files: __static__\1index.html
upload: __NOT_USED__
require_matching_file: True
login: optional
secure: optional
- url: (/.*)
static_files: __static__\1
upload: __NOT_USED__
require_matching_file: True
login: optional
secure: optional
- url: /.*
script: unused
login: optional
secure: optional

Can someone tell me if there is a way to edit the app.yaml file before deploying in the appengine java standard environment. A similar question has been posted recently but there is no response for the moment.

解决方案

I think you're confusing angular routing, which happens on the browser side, from the server-side URL routing, which is described by a web.xml.

My guess is that your web.xml is missing a welcome file to load the index.html. For example, here's a simple web.xml that should do the trick:

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
 <welcome-file-list>
   <welcome-file>index.html</welcome-file>
 </welcome-file-list>
</web-app>

这篇关于在GAE java标准环境中配置路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆