2012-05-13 5 views
0

のWebContent - リソース - CSS - style.cssに WEB-INF - index.htmlをのRestlet CSSやJavaScriptファイル

public synchronized Restlet createInboundRoot() { 
    Router router = new Router(getContext()); 
    router.attach("/", IndexResource.class); 
    return router; 
} 

IndexResourceはHTML Respresentation(index.htmlを)を実行

私のindex.htmlでは、私はCSSファイルを指定しました。問題はそれが見つからないということです。

<link href="/resources/css/style.css" rel="stylesheet" type="text/css"> 

私は/resources/css/style.cssはRestletのではなく、実際のファイル・パスを経由して起こっていると思います。サーブレット(Restlet)として実行するリソースフォルダを停止するにはどうすればよいですか?

+0

可能な重複:http://stackoverflow.com/questions/9651019/cant-get-resource-files-in-my-template-files-using-restlet-and-freemarker –

+0

あなたのリンクを " resources/css/style.css "の代わりに – Sean

答えて

1

あなたのCSSファイルはRestletによって提供される必要がありますか?その場合は(アプリケーションクラスで)以下に説明するように、あなたはディレクトリクラスを使用して検討する必要があります。この場合

public Restlet createInboundRoot() { 
    Router router = new Router(getContext()); 
    (...) 
    router.attach("/resources", new Directory(getContext(), "file://<STATIC_DIR>")); 
} 

をあなたはフォルダの下のcss/style.cssにしておく必要があります。

お手伝いします。 Thierry

+0

私はそれがレシートによって提供されないことを望むだろうが、それは常にサーブレットとして行く。私はそれを止める方法がわかりません。私が付いているのは次のとおりです: router.attach( "/"、IndexResource.class); – Decrypter

+0

の場合、 C:/ Users//rest/webapp /またはC:/ Users//rest/webapp/resources – Decrypter

関連する問題