我正在尝试设置两个不同的静态 Assets 路由,第二个失败了。我错过了什么?
要复制问题:
GET /assets/*file controllers.Assets.at(path="/public", file)
GET /assets2/*file controllers.Assets.at(path="/public2", file)
$ cat > public/foo.txt
hi
$ mkdir public2
$ cp public/foo.txt public2
$ telnet localhost 9000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /assets/foo.txt HTTP/1.0
HTTP/1.1 200 OK
Content-Length: 3
Content-Type: text/plain
Etag: 5246040afe91a4cc93bd838a4d5db3984b99470b
Cache-Control: no-cache
hi
Connection closed by foreign host.
$ telnet localhost 9000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /assets2/foo.txt HTTP/1.0
HTTP/1.1 404 Not Found
Content-Length: 0
Connection closed by foreign host.
我敢肯定这里有一些明显的东西,我只是没看到。
最佳答案
您应该添加 public2
文件夹到 playAssetsDirectories
在 sbt 配置中
playAssetsDirectories <+= baseDirectory / "public2"
见 PlaySettings举个例子。
关于scala - Play Framework 2.0 多条静态路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10185956/