简体   繁体   English

JSF 2.2-找不到“链接”标签

[英]JSF 2.2 - No “link” tag found

I would like to add a link in a JSF page. 我想在JSF页面中添加一个链接。 This is my code 这是我的代码

<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Hey!</title>
</head>
<body>
  <f:view>

    <h:link value="Hey" outcome="dateMe" />
  </f:view>
</body>
</html> 

When I run it, I get 当我运行它时,我得到

org.apache.jasper.JasperException: /index.jsp (line: 11, column: 4) No tag "link" defined in tag library imported with prefix "h"

I've read that this tag was introduced with JSF 2.0, but I checked and I'm using JSF 2.2. 我已经读到该标签是JSF 2.0引入的,但是我检查了一下,然后使用JSF 2.2。

What am I missing? 我想念什么?

Try this: 尝试这个:

<h:commandLink value="Hey" action="#{bean.action}" onclick="function()" />

You'll get the same functionality with different attributes. 您将获得具有不同属性的相同功能。 You could also consider: 您还可以考虑:

<h:outputLink value="page.xhtml">
    <h:outputText value="Hey" />
</h:outputLink>

EDIT 编辑

Make sure your faces-config.xml is this. 确保您的faces-config.xml是这个。 <h:link> is a newer component of JSF 2.0. <h:link>是JSF 2.0的较新组件。 Also make sure that you don't have JSF 1.x libraries in your /WEB-INF/lib , you need JSF 2.0 libraries. 还要确保/WEB-INF/lib没有JSF 1.x库,您需要JSF 2.0库。

<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">

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

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