在 Icefaces 中使用 Spring Security 登录不起作用
Posted
技术标签:
【中文标题】在 Icefaces 中使用 Spring Security 登录不起作用【英文标题】:Login not working using Spring Security in Icefaces 【发布时间】:2011-07-01 21:58:51 【问题描述】:我正在尝试使用带有 Spring 安全性的 Icefaces 登录。由于某种原因,我无法成功登录我的应用程序。 即使我使用提供正确的身份验证详细信息,它也总是给出错误的用户名或密码。 我正在使用 Icefaces 1.8.2 和 JSF 1.1。
有人可以提供一些帮助,说明为什么尽管提供了正确的身份验证详细信息,但我还是无法成功登录。
我是按照here的例子来的
我的 login.jspx
<?xml version="1.0" encoding="ISO-8859-1" ?>
<f:view xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<ice:outputDeclaration doctypeRoot="HTML"
doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN"
doctypeSystem="http://www.w3.org/TR/html4/loose.dtd"/>
<html>
<head>
<title>Spring Security Login</title>
</head>
<body>
<ice:form partialSubmit="false">
<ice:panelGrid columns="2">
<ice:outputLabel value="User Name" for="j_username"/>
<ice:inputText id="j_username"
value="#loginBean.userId" size="40"
maxlength="80"/>
<ice:outputLabel value="Password" for="j_password"/>
<ice:inputSecret id="j_password"
value="#loginBean.password" size="40"
maxlength="80"/>
</ice:panelGrid>
<ice:commandButton actionListener="#loginBean.login" value="Login"/>
<ice:messages style="color: red;"/>
</ice:form>
</body>
</html>
</f:view>
还有我的loginBean登录方法
public void login(ActionEvent e) throws java.io.IOException
HttpServletRequest req =
(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
FacesContext.getCurrentInstance().getExternalContext().redirect(req.getContextPath().toString() +
"/j_spring_security_check?j_username=" +
userId + "&j_password=" +
password);
【问题讨论】:
【参考方案1】:好的,我设法让它使用普通的旧 jsp 工作,而不是 jsf,并且表单操作方法必须是 POST
我的登录.jsp
<form action="j_spring_security_check" method="POST">
<label for="j_username">Username</label>
<input type="text" name="j_username" id="j_username"/><br/>
<label for="j_password">Password</label>
<input type="password" name="j_password" id="j_password"/><br/>
<input type="submit" value="Login"/>
</form>
【讨论】:
以上是关于在 Icefaces 中使用 Spring Security 登录不起作用的主要内容,如果未能解决你的问题,请参考以下文章
JBoss RichFaces vs IceFaces vs Apache Trinidad - JSF 组件库比较