JSF 无法提供已经存在的资源
JSF failing to serve a ressource which is already there
我有一个 JSF 应用程序,需要登录
<h:commandButton id="btnLoginId" value="Login" action="#{UserLoginMB.login}" styleClass="loginPanelBtn"></h:commandButton>
工作并将 "correct" 结果发送给 managedBean,
public String login() {
// ...
return "correct";
}
在那之后,return 说:
Impossible de trouver un cas de navigation correspondant depuis l’ID
de vue «/home/index.xhtml» pour l’action «#{UserLoginMB.login}» avec
le résultat «correct».
这意味着无法找到与视图 ID home/index.xhtml 对应的导航方式(Bean.login),结果为 "correct"
虽然我已将 Faces 配置设置为在成功结果的情况下重定向到 /home/backend/index.xhtml(正确 return),
<!-- navigation-rule for login.xhtml -->
<navigation-rule>
<from-view-id>/home/index.xhtml</from-view-id>
<!-- navigation-case for method login() -->
<navigation-case>
<from-action>#{userLoginMB.login}</from-action>
<from-outcome>correct</from-outcome>
<to-view-id>/home/backend/index.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
并且在 apache 日志中:
AVERTISSEMENT: JSF1064 : Impossible de localiser ou de servir une
ressource, /home/correct.xhtml.
这意味着无法本地化资源 /home/correct.xhtml,而我从未使用过这样的资源。
如果 <from-view-id>
或 <from-action>
不完全匹配(它们区分大小写!)就会发生这种情况,因此 JSF 无法找到具有所需结果的关联 <navigation-case>
.然后 JSF 将默认为隐式导航,这意味着 returned 字符串将被视为 <to-view-id>
.
所以,例如
public String login() {
// ...
return "correct";
}
并且找不到 <navigation-case>
,那么 JSF 将隐式导航到与当前视图位于同一文件夹中的 correct.xhtml
。此功能是自 JSF 2.0 以来的新功能,它使开发人员无需编写所有充满导航案例的 XML 样板。在您的特定情况下,您也可以 return "backend/index"
.
而不是使用导航案例
public String login() {
// ...
return "backend/index";
}
另请参阅:
- JSF implicit vs. explicit navigation
我有一个 JSF 应用程序,需要登录
<h:commandButton id="btnLoginId" value="Login" action="#{UserLoginMB.login}" styleClass="loginPanelBtn"></h:commandButton>
工作并将 "correct" 结果发送给 managedBean,
public String login() {
// ...
return "correct";
}
在那之后,return 说:
Impossible de trouver un cas de navigation correspondant depuis l’ID de vue «/home/index.xhtml» pour l’action «#{UserLoginMB.login}» avec le résultat «correct».
这意味着无法找到与视图 ID home/index.xhtml 对应的导航方式(Bean.login),结果为 "correct"
虽然我已将 Faces 配置设置为在成功结果的情况下重定向到 /home/backend/index.xhtml(正确 return),
<!-- navigation-rule for login.xhtml -->
<navigation-rule>
<from-view-id>/home/index.xhtml</from-view-id>
<!-- navigation-case for method login() -->
<navigation-case>
<from-action>#{userLoginMB.login}</from-action>
<from-outcome>correct</from-outcome>
<to-view-id>/home/backend/index.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
并且在 apache 日志中:
AVERTISSEMENT: JSF1064 : Impossible de localiser ou de servir une ressource, /home/correct.xhtml.
这意味着无法本地化资源 /home/correct.xhtml,而我从未使用过这样的资源。
如果 <from-view-id>
或 <from-action>
不完全匹配(它们区分大小写!)就会发生这种情况,因此 JSF 无法找到具有所需结果的关联 <navigation-case>
.然后 JSF 将默认为隐式导航,这意味着 returned 字符串将被视为 <to-view-id>
.
所以,例如
public String login() {
// ...
return "correct";
}
并且找不到 <navigation-case>
,那么 JSF 将隐式导航到与当前视图位于同一文件夹中的 correct.xhtml
。此功能是自 JSF 2.0 以来的新功能,它使开发人员无需编写所有充满导航案例的 XML 样板。在您的特定情况下,您也可以 return "backend/index"
.
public String login() {
// ...
return "backend/index";
}
另请参阅:
- JSF implicit vs. explicit navigation