문제

나는 나의 플레이 앱 실행:

http://localhost:9000

Nginx 은 프록시에 전달하 this url:

http://localhost/Demo/

내가 문제가 있으로 정적 하지만입니다.예를 들어,이 자산은 html 에서는 템플릿

<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">

http://localhost/assets/stylesheets/main.css

분명히 결과를 찾을 수 없다.변경하면 나는 이(추가 /Demo 앞에서의 url):

<link rel="stylesheet" media="screen" href="/Demo@routes.Assets.at("stylesheets/main.css")">

그것이 지금 제대로 이동하는 url:

http://localhost/Demo/assets/stylesheets/main.css

나의 질문은:어떻게 추가할 수 있습니이 /Demo 내 모든 정적 자산을 없이 하드 codding 내 템플릿?세요 이를 해결하기 위해 사용하는 재생의 라우팅 및 제한을 변경하 nginx conf.

나는 시도했다 추가하는 url 접두사로 application.conf 다음과 같이

application.context="/Demo"

그러나 영향을 받는 모든 url 뿐만 아니라 정적들,그래서 해결책이 아닙니다.어떤 생각?

내택:플레이 2.2.1/ Scala2.10.3/ Java8 64bit/ Nginx1.4.3/ 우분투 13.10 64bit

업데이트:솔루션 감사@biesior 제공을 위한 Java 버전,난로 변환하 scala:

package core

import controllers.routes

object Assets {

    def at(path: String): String = {
        "/Demo" + routes.Assets.at(path)
    }

}
도움이 되었습니까?

해결책

그냥 overwite 을 사용하여 경로를 자신의 구현은 자산을(즉,.에 utils 패키지):

package utils;
import controllers.routes;

public class MyAssets {
    public static String at(String path){
        return "/Demo"+ routes.Assets.at(path).toString();
    }
}

에서는 템플릿:

<img src='@utils.MyAssets.at("images/logo.png")' alt="">

에서 꽤 다른 한편으로,대상 프로젝트에서 작동 하위 디렉토리?하지 않을 경우 그것은 단지 사용하기 쉽게 하위 도메인은,그것이 가능한 localhost,그 구성 nginx 해당 프로젝트에 사용하는 ie.: http://demo.loc 대신 od http://localhost/Demo 과이 '도메인' 귀하의 hosts 파일

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top