Shiro一直重定向到登录页面

时间:2012-09-21 17:50:24

标签: xml jsp shiro

我正在尝试在我的网络应用程序中实现shiro,无论我尝试什么,我都会遇到这个问题。我已经查看Shiro always redirects me to login.jsphttp://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

的login.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>

的web.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。

0 个答案:

没有答案