使用jsf 2时获取f:ajax的未知标记警告

时间:2012-04-04 01:09:07

标签: jsf

我正在使用eclipse。在WEB-INF / lib文件夹中,我有以下罐子。

jstl-api-1.2.jar
jstl-impl-1.2.jar
myfaces-api-2.0.2.jar
myfaces-impl.2.0.2.jar

我收到以下警告

Multiple annotations found at this line:
    - Unknown tag (f:ajax).
    - Unknown tag (f:ajax).

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>no</title>
</head>
<body>
<f:view>
    <h:form id="form1">
        <h:commandButton value="submit" type="submit" action="#{registrationBean.storeUserId}" >
             <f:ajax render="node1" />
        </h:commandButton>
        <br>
        <h:outputText id="node1" value="#{userIdBean.userId}" style="font-weight:bold" />
    </h:form>
</f:view>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

古代JSP视图技术不支持<f:ajax>。它仅在其继任者Facelets中得到支持。

page.jsp重命名为page.xhtml并重写代码符合Facelets语法:

<!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"
>
    <h:head>
        <title>no</title>
    </h:head>
    <h:body>
        <h:form id="form1">
            <h:commandButton value="submit" type="submit" action="#{registrationBean.storeUserId}" >
                 <f:ajax render="node1" />
            </h:commandButton>
            <br>
            <h:outputText id="node1" value="#{userIdBean.userId}" style="font-weight:bold" />
        </h:form>
    </h:body>
</html>

学习JSF 2.x时,请确保您正在阅读JSF 2.x资源/教程/书籍,而不是JSF 1.x。

另见:

相关问题