0

WebContent - resources - css - style.css WEB-INF - index.html

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

The IndexResource executes an HTML Respresentation (index.html)

In my index.html I have specified a css file. The problem is that it cannot be found.

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

I think /resources/css/style.css is going via restlet and not the actual file path. How do I stop the resources folder executing as a servlet (restlet)?

Decrypter
  • 2,784
  • 12
  • 38
  • 57
  • Possible duplicate: http://stackoverflow.com/questions/9651019/cant-get-resource-files-in-my-template-files-using-restlet-and-freemarker – Chris White May 13 '12 at 18:36
  • try making your link relative "resources/css/style.css" instead of absolute – Sean May 14 '12 at 09:32

1 Answers1

1

Must your css file need to be served by Restlet? If so, you should consider using the Directory class as described below (in your application class):

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

In this case you need to have css/style.css under the folder.

Hope it helps you. Thierry

Thierry Templier
  • 198,364
  • 44
  • 396
  • 360
  • I would prefer it not to be served by restlet but it always goes through as a servlet. I'm not sure how to stop it.All I attach is: router.attach("/", IndexResource.class); – Decrypter May 16 '12 at 19:55
  • When you stay do you mean: C:/Users//rest/webapp/ or C:/Users//rest/webapp/resources – Decrypter May 16 '12 at 20:29