mjn*_*mjn 7 favicon resources jsf jsf-2
使用h:outputStylesheet我可以在HTML head部分中嵌入CSS资源,但是如何在这个示例中构建一个呈现HTML <link>的favicon图像资源:
HTML输出:
<head>
...
<link rel="icon" type="image/png" href="favicon.png" />
...
</head>
Run Code Online (Sandbox Code Playgroud)
图像资源位于<web>/resources/images.
如果我在JSF模板中使用直接HTML代码,就像href="/resources/images/favicon.png"找不到资源一样- 导航到/resources/images/favicon.png会导致错误
找不到/resources/images/favicon.png/index.jsf
(我已将index.jsf设置为web.xml中的索引页面,可能会解释此路径)
Bal*_*usC 10
您的webapp显然是在非空的上下文路径上运行.前导斜杠/将您带到域根目录.使用#{request.contextPath}动态内联上下文路径.
<link rel="shortcut icon" type="image/png" href="#{request.contextPath}/resources/images/favicon.png" />
Run Code Online (Sandbox Code Playgroud)
(注意我也固定了rel它以使它与crossbrowser兼容)
| 归档时间: |
|
| 查看次数: |
7327 次 |
| 最近记录: |