我正在尝试在我的网络应用程序中实现 shiro,无论我尝试什么,我都会遇到这个问题。我已经看过Shiro 总是将我重定向到 login.jsp和http://mail-archives.apache.org/mod_mbox/shiro-user/201204.mbox/%3CCAETPiXbFDzOZnj4qOaRXgMv57NisN1xk9wfCGaO+vPM5hR5j3A@mail.gmail.com%3E没有成功。
这是我的相关代码:
shiro.ini:
[main]
authc.loginUrl = /public/login.jsp
authc.usernameParam = user
authc.passwordParam = pass
authc.rememberMeParam = remember
authc.successUrl = /private/other.xhtml
authc.failureKeyAttribute=LoginFailure
[users]
admin=admin,ROLE_ADMIN
[roles]
ROLE_ADMIN=*
[urls]
/public/login.jsp=authc
/private/**=authc
登录.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Please Log In</title>
</head>
<body>
<%
String errorDescription = (String) request.getAttribute("LoginFailure");
if (errorDescription!=null) {
%>
Login attempt was unsuccessful: <%=errorDescription%>
<%
}
%><form name="loginform" action="" method="post">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>Username:</td>
<td><input type="text" name="user" maxlength="30"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pass" maxlength="30"></td>
</tr>
<tr>
<td colspan="2" align="left"><input type="checkbox" name="remember"><font size="2">Remember Me</font></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="submit" value="Login"></td>
</tr>
</table>
</form>
</body>
</html>
网页.xml:
<welcome-file-list>
<welcome-file>/index.xhtml</welcome-file>
</welcome-file-list>
<filter>
<filter-name>securityFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
<init-param>
<param-name>configPath</param-name>
<param-value>classpath:shiro.ini</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>securityFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
即使我输入了正确的登录信息,我也会不断被重定向回 login.jsp。