“该链接被停用,因为它没有以JSF形式嵌入." [英] "This link is deactivated, because it is not embedded in a JSF form."

查看:119
本文介绍了“该链接被停用,因为它没有以JSF形式嵌入."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用以下命令链接时:

When I use the following command link:

<h:commandLink action="student" value="students" />

以及faces-config.xml中的以下导航规则:

And the following navigation rule in faces-config.xml:

<navigation-rule>
  <from-view-id>/home.xhtml</from-view-id>
  <navigation-case>
    <from-outcome>student</from-outcome>
    <to-view-id>/student.xhtml</to-view-id>
  </navigation-case>
</navigation-rule>

然后我得到以下开发阶段面临的消息:

Then I get the following development stage faces message:

此链接未激活,因为它未嵌入JSF表单中.

This link is deactivated, because it is not embedded in a JSF form.

这是怎么引起的,我该如何解决?

How is this caused and how can I solve it?

推荐答案

<h:commandLink>触发POST请求.您需要将其嵌入到<h:form>中.

The <h:commandLink> fires a POST request. You need to embed it in a <h:form>.

<h:form>
    <h:commandLink action="student" value="students" />
</h:form>

由于您已经在使用JSF 2.0,因此也可以只使用<h:link>来触发不需要表单的GET请求,因此对于书签性和SEO而言要好得多.另外,由于JSF 2.0使用隐式导航,因此您也可以摆脱整个<navigation-rule>.

Since you're already on JSF 2.0, you can also just use <h:link> instead which fires a GET request which doesn't require a form and is thus way much better for bookmarkability and SEO. Also you can get rid of the whole <navigation-rule> since JSF 2.0 utilizes implicit navigation.

<h:link value="students" outcome="student" />

它将隐式转到student.xhtml.

确保您正在阅读JSF 2.0教程,而不是针对JSF 1.x的教程.在JSF 2.0中,添加了许多新的标签和功能.

Ensure that you're reading JSF 2.0 tutorials, not the ones targeted on JSF 1.x. In JSF 2.0 a lot of new tags and features have been added.

  • When should I use h:outputLink instead of h:commandLink?
  • We don't need stinkin' faces-config

这篇关于“该链接被停用,因为它没有以JSF形式嵌入."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆