2012-04-17 10 views
4

2つの異なるスタティックアセットルートを設定しようとしていますが、2つ目は失敗します。私は何が欠けていますか? Scalaのサンプルからのhello世界とPlay Framework 2.0複数のスタティックルート

  1. 開始:

    は、問題を複製します。

  2. 2つのスタティックルートがあるので、今、ルートに行を追加します。

    GET  /assets/*file  controllers.Assets.at(path="/public", file) 
    GET  /assets2/*file  controllers.Assets.at(path="/public2", file) 
    
  3. コメントアウトmain.scala.htmlにおける資産の参照は、それはそれらについて

  4. を文句はありません
  5. ファイルをpublicとpublic2に配置します。

    $ cat > public/foo.txt 
    hi 
    $ mkdir public2 
    $ cp public/foo.txt public2 
    
  6. 公開ディレクトリが動作することを確認します。

    $ 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. 
    
  7. 2番目が機能しないことを確認します。

    $ 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. 
    

私は "mはちょうどそれを見ていない、明らかに何かがここにあります確信している。

答えて

5

あなたは

playAssetsDirectories <+= baseDirectory/"public2" 

PlaySettingsを参照してくださいSBTの設定でplayAssetsDirectoriespublic2フォルダを追加する必要があります

+0

ああ私の神、固定。ありがとう。 –

+3

が追加されました。次世代をいくらか保存するためにwikiには少ししかない。 https://github.com/playframework/Play20/wiki/Assets –

+0

PlaySettingsがどのように役立つかについて具体的にお答えください。 PlaySettingsに文字列 "playAssetsDirectories"または "baseDirectory /"がありません。ありがとう –

関連する問題