Can I add a meta tag to a particular page that is using templates

馋奶兔 提交于 2019-12-22 13:57:00

问题


I have a page that uses a template

<ui:composition template="/WEB-INF/facelets/templates/clientPage.xhtml">

I was hoping to only render the compatibility view for this particular page using the meta tag

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

The tag does not work unless I add it to the root template page. Is there a way I can add it to specific pages that use the template.


回答1:


Declare an <ui:insert> in the master template at the desired location:

clientPage.xhtml

<!DOCTYPE html>
<html ...>
    ...
    <h:head>
        <ui:insert name="head-meta" />
        ...
    </h:head>
    ...
</html>

Extend the master template with another master template:

i18ClientPage.xhtml

<ui:composition template="/WEB-INF/facelets/templates/ie8ClientPage.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
>
    <ui:define name="head-meta">
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    </ui:define>
</ui:composition>

Finally let those template clients use this master template instead.



来源:https://stackoverflow.com/questions/19307646/can-i-add-a-meta-tag-to-a-particular-page-that-is-using-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!