2012-05-13 47 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而不是實際的文件路徑。如何停止作爲servlet(restlet)執行的資源文件夾?

+0

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

+0

嘗試使您的鏈接相對「資源/ css/style.css「而不是絕對的 – Sean

回答

1

你的CSS文件需要由Restlet提供嗎?如果是這樣,你應該如下所示(在你的應用程序類)考慮使用Directory類:

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

在這種情況下,你需要有文件夾下的css/style.css中。

希望它可以幫助你。 Thierry

+0

我寧願它不是由restlet提供服務,但它始終作爲一個servlet。我不知道如何阻止它。我附上的是: router.attach(「/」,IndexResource.class); – Decrypter

+0

當您入住您的意思是: C:/ Users//rest/webapp /或C:/ Users//rest/webapp/resources – Decrypter