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)?

2
  • Possible duplicate: stackoverflow.com/questions/9651019/… Commented May 13, 2012 at 18:36
  • try making your link relative "resources/css/style.css" instead of absolute Commented May 14, 2012 at 9:32

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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);
When you stay <STATIC_DIR> do you mean: C:/Users/<MyUsername>/rest/webapp/ or C:/Users/<MyUsername>/rest/webapp/resources

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.