我有一个网络应用程序,我希望主页包括一个登录表单,以及其他数据。如果用户选择登录,他应该被重定向到另一个页面(例如login_success.jsp)。我的问题是:我能否使用j_security_check机制进行登录,或者唯一的方法是使用托管bean来处理登录?
我的主页看起来像这样:
如果我按下登录按钮,会出现“HTTP状态400 - 无效的直接引用表单登录页面”的提示。很明显,j_security_check机制不知道要“重定向”到哪里,因为我之前没有请求受保护的资源。
我的主页看起来像这样:
....
<form action="j_security_check" method="POST" name="loginForm">
<h:panelGrid columns="2">
<h:outputLabel id="userNameLabel" for="j_username" value="#{label.home_username}:" />
<h:inputText id="j_username" autocomplete="off" />
<h:outputLabel id="passwordLabel" for="j_password" value="#{label.home_password}:" />
<h:inputSecret id="j_password" autocomplete="off" />
<h:panelGroup>
<h:commandButton type="submit" value="Login" />
<h:commandButton type="reset" value="Clear" />
</h:panelGroup>
</h:panelGrid>
</form>
...
如果我按下登录按钮,会出现“HTTP状态400 - 无效的直接引用表单登录页面”的提示。很明显,j_security_check机制不知道要“重定向”到哪里,因为我之前没有请求受保护的资源。