繁体   English   中英

使用 jsf 时收到 f:ajax 的未知标签警告 2

[英]Getting an unknown tag warning for f:ajax while using jsf 2

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

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>

古老的 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 的。

也可以看看:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM