【发布时间】:2011-08-08 14:07:59
【问题描述】:
为了替换默认的 Spring 安全登录表单,我想出了这个解决方案:
<form name="f" action="../j_spring_security_check" method="POST" >
<h:panelGrid columns="2">
<h:outputText value="Username" />
<h:inputText id="j_username" />
<h:outputText value="Password" />
<h:inputText id="j_password" />
</h:panelGrid>
<h:commandButton value="Login" />
</form>
但我想使用<h:form> 而不是普通的<form> 标签,因为Primefaces 组件只能在<h:form> 中工作。使用<h:form>,表单动作将由 JSF 自动设置为当前页面,而不是我在上面的示例中设置的值。我现在必须在哪里编写动作"../j_spring_security_check"?我尝试将其放入<h:commandButton>,如下所示,但这不起作用:
<h:form name="f">
<h:panelGrid columns="2">
<h:outputText value="Username" />
<h:inputText id="j_username" />
<h:outputText value="Password" />
<h:inputText id="j_password" />
</h:panelGrid>
<h:commandButton value="Click here" action="../j_spring_security_check" />
</form>
导致错误信息Unable to find matching navigation case with from-view-id '/login.xhtml' for action '../j_spring_security_check' with outcome '../j_spring_security_check'。
这是在faces-config.xml 中定义导航案例的唯一方法吗?我想避免在这个简单的用例中使用 bean。
【问题讨论】:
-
See this answer 关于
h:commandButton操作 -
@Matt:不幸的是,要调用的站点
../j_spring_security_check不是XHTML 站点。您提供的链接是假定的。