当我使用以下命令链接时:
<h:commandLink action="student" value="students" />
Run Code Online (Sandbox Code Playgroud)
以下导航规则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>
Run Code Online (Sandbox Code Playgroud)
然后我得到以下开发阶段面部消息:
此链接已停用,因为它未嵌入JSF表单中.
这是怎么造成的,我该如何解决?
Bal*_*usC 10
所述<h:commandLink>火灾POST请求.你需要把它嵌入一个<h:form>.
<h:form>
<h:commandLink action="student" value="students" />
</h:form>
Run Code Online (Sandbox Code Playgroud)
既然你已经在JSF 2.0上了,你也可以使用<h:link>它来激发一个不需要表单的GET请求,因此对于可书签性和SEO更好.此外,您可以摆脱整体,<navigation-rule>因为JSF 2.0使用隐式导航.
<h:link value="students" outcome="student" />
Run Code Online (Sandbox Code Playgroud)
它会隐含地去student.xhtml.
确保您正在阅读JSF 2.0教程,而不是针对JSF 1.x的教程.在JSF 2.0中,添加了许多新标签和功能.