2
JSF中是否有一个taglib用于在我想要的任何URL中插入正确的应用程序上下文根,就像JSP中的<c:url>
标记一样?JSF有类似<c:url>的东西吗?
JSF中是否有一个taglib用于在我想要的任何URL中插入正确的应用程序上下文根,就像JSP中的<c:url>
标记一样?JSF有类似<c:url>的东西吗?
并非如此,但引用URL资源的所有JSF组件都已自动包含适当的上下文路径,并最终还会映射到映射。例如,<h:link>
:
<h:link value="Link to other page" outcome="otherpage" />
这使得类似的东西(假设你的上下文路径是/contextname
和你FacesServlet
被映射在*.xhtml
):
<a href="/contextname/otherpage.xhtml">Link to other page</a>
您可以通过<f:param>
包括请求参数:
<h:link value="Link to other page" outcome="otherpage">
<f:param name="foo" value="#{bean.foo}" />
</h:link>
它呈现类似于:
<a href="/contextname/otherpage.xhtml?foo=bar">Link to other page</a>
其他链接部件也做是<h:outputStylesheet>
,<h:outputScript>
和<h:graphicImage>
对CSS,分别JS和图像:
<h:outputStylesheet library="default" name="css/foo.css" />
<h:outputScript library="default" name="js/foo.js" />
<h:graphicImage library="default" name="images/foo.png" />
这使得类似:
<link rel="stylesheet" type="text/css" href="/contextname/javax.faces.resource/css/foo.css.xhtml?ln=default" />
<script type="text/javascript" src="/contextname/javax.faces.resource/js/foo.js.xhtml?ln=default"></script>
<img src="/contextname/javax.faces.resource/images/foo.png.xhtml?ln=default" />
好的,谢谢......正是我需要的! –
不客气。 – BalusC