首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ui:insert未被ui替换:定义

ui:insert未被ui替换:定义
EN

Stack Overflow用户
提问于 2015-01-13 12:05:45
回答 1查看 905关注 0票数 2

我正在创建一个JSF模板,以遵循我的应用程序的布局。所以我创建了这个layout.xhtml页面。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html">

<h:head>
    <link href="stylesheet.css" rel="stylesheet" type="text/css" />
</h:head>
<h:body>
    <f:loadBundle basename="mensagens.mensagens_pt_BR" var="msgs" />
    <ui:composition>
        <div id="page">
            <div id="header-container">
                <div id="nomeSistema">#{msgs.outNomeSistema}</div>
            </div>
            <div id="menu-login-container">
                <div id="menu"
                    style="width: 850px; height: 30px; border: solid 1px; padding: 15px;">
                    <ui:include src="/menu/menu.xhtml" />
                </div>
                <div id="login">
                    <ui:include src="/login/login.xhtml" />
                </div>
            </div>
            <div id="content-container">
                <div id="content">
                    <ui:insert name="content">
                        <h2>Default content</h2>
                    </ui:insert>
                </div>
            </div>
            <div id="footer-container">
                <div id="footer">
                    <h:outputText value="#{msg.versao}" />
                </div>
            </div>
        </div>
    </ui:composition>
</h:body>
</html>

这是comum.xhtml

代码语言:javascript
复制
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets" template="layout.xhtml">
    <ui:define name="content">
        <h2>Testando template...</h2>
    </ui:define>
</ui:composition>

但是,当我访问浏览器上的comum.xhtml页面时。文本默认内容显示,而不是Testando模板.

我做错什么了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-13 13:17:05

我找到了!

layout.xhtml的html标记上,我将其改为

代码语言:javascript
复制
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html">

代码语言:javascript
复制
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">

现在,它起作用了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27921776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档