Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 带有JSF主体的JSP自定义标记_Java_Jsp_Jsf_Tomcat_Custom Tags - Fatal编程技术网

Java 带有JSF主体的JSP自定义标记

Java 带有JSF主体的JSP自定义标记,java,jsp,jsf,tomcat,custom-tags,Java,Jsp,Jsf,Tomcat,Custom Tags,我打算为一个网站创建自己的模板机制。我制作了两个名为“TemplateInsert”和“TemplateFor”的自定义标记,其中一个使用它们的方式如下: <prefix:insert templateFile="someFile> <prefix:for name="body"> some content here </prefix:for> other prefix:for tags... </prefix

我打算为一个网站创建自己的模板机制。我制作了两个名为“TemplateInsert”和“TemplateFor”的自定义标记,其中一个使用它们的方式如下:

<prefix:insert templateFile="someFile>
    <prefix:for name="body">
        some content here
    </prefix:for>

    other prefix:for tags...

</prefix:insert>

这就是为什么jsf2.0/javaee6中Facelets成功使用JSP的众多原因之一。JSP提供的模板功能很少。但是,如果您按照各自的要求单独安装Facelets 1.x,则可以在JSF 1.x上使用Facelets 1.x

Facelets正好提供了您的功能需求。例如:

template.xhtml

<!DOCTYPE html>
<html lang="en"
    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"
>
    <head>
        <title><ui:insert name="title" /></title>
    </head>
    <body>
        <ui:insert name="body" />
    </body>  
</html>
<ui:composition template="template.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"
>
    <ui:define name="title">Page title</ui:define>
    <ui:define name="body">
        <h:outputText value="JSF tags just work here." />
    </ui:define>
</ui:composition>

我想说的是,把Facelets作为JSF视图技术,而不是重新发明一种基于JSP的技术。

这就是为什么根据JSF 2.0/Java EE 6,Facelets已经成功使用JSP的众多原因之一。JSP提供的模板功能很少。但是,如果您按照各自的要求单独安装Facelets 1.x,则可以在JSF 1.x上使用Facelets 1.x

Facelets正好提供了您的功能需求。例如:

template.xhtml

<!DOCTYPE html>
<html lang="en"
    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"
>
    <head>
        <title><ui:insert name="title" /></title>
    </head>
    <body>
        <ui:insert name="body" />
    </body>  
</html>
<ui:composition template="template.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"
>
    <ui:define name="title">Page title</ui:define>
    <ui:define name="body">
        <h:outputText value="JSF tags just work here." />
    </ui:define>
</ui:composition>
我想说的是,将Facelets作为JSF视图技术,而不是基于JSP重新发明Facelets