在App Engine Java中将动态URL路由到静态文件。

huangapple go评论81阅读模式
英文:

Route dynamic URLs to static files in App Engine Java

问题

我有一个Java App Engine应用程序,想要将mydomain.com/i/<anything>路由到i.html。例如:

mydomain.com/i/12345 --> i.html

mydomain.com/i/abcde --> i.html

Python的app.yamlGo的app.yaml中,似乎可以通过以下方式实现:

handlers:
  - url: /i/(.*)
    static_files: i.html

但是在Java的app.yaml中,并没有提到将处理程序映射到静态文件的方法。相反,有一个单独的静态文件和资源文件部分,不能进行URL映射,而在handlers中映射URL的选项只能是servletjspfilter。如果我尝试在Java的app.yaml中映射到static_files,会出现Unable to find property 'static_files'错误。

关键在于,我想要将一个URL映射到作为静态文件提供的静态文件。为什么这只能在Python和Go中实现,而在Java中却不能呢?

英文:

I have a Java App Engine app and want to route mydomain.com/i/<anything> to i.html. For example:

mydomain.com/i/12345 --> i.html

mydomain.com/i/abcde --> i.html

This looks like it is possible to do in app.yaml for Python and app.yaml for Go with something like:

handlers:
  - url: /i/(.*)
    static_files: i.html

but this handler mapping to static files is NOT mentioned in app.yaml for Java. Instead, there is a separate Static files and resource files section that cannot do url mappings, and the only options to map a url in handlers is to a servlet, jsp, or filter. If I try to map to static_files in a Java app.yaml, I get an Unable to find property 'static_files' error.

The key here is that I want to map a url to a static file that is served as a static file. Why would this be only possible to do in Python and Go, and not in Java?

答案1

得分: 1

我不使用Java版本,但是看起来appengine-web.xml的作用与Go/Python中的app.yaml相同。

英文:

I dont use the java version but it looks like the appengine-web.xml serves the same function as the app.yaml in go / python?

huangapple
  • 本文由 发表于 2015年3月8日 04:05:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/28919397.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定