网页内容 - 资源 - CSS - 样式.css 网络信息 - index.html
public synchronized Restlet createInboundRoot() {
Router router = new Router(getContext());
router.attach("/", IndexResource.class);
return router;
}
IndexResource 执行 HTML 表示 (index.html)
在我的 index.html 中,我指定了一个 css 文件。问题是找不到。
<link href="/resources/css/style.css" rel="stylesheet" type="text/css">
我认为 /resources/css/style.css
是通过 reSTLet 而不是实际的文件路径。如何停止作为 servlet (reSTLet) 执行的资源文件夹?
最佳答案
您的 css 文件必须由 ReSTLet 提供服务吗?如果是这样,您应该考虑使用如下所述的 Directory 类(在您的应用程序类中):
public Restlet createInboundRoot() {
Router router = new Router(getContext());
(...)
router.attach("/resources", new Directory(getContext(), "file://<STATIC_DIR>"));
}
在这种情况下,您需要在文件夹下有 css/style.css。
希望对你有帮助。 蒂埃里
关于tomcat - ReSTLet css 和 javascript 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10572094/