</pre><pre name="code" class="html"><bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="/login"/>
<property name="successUrl" value="/first" />
<property name="filters">
<util:map>
<entry key="authc" value-ref="formAuthenticationFilter"/>
</util:map>
</property>
<property name="filterChainDefinitions">
<value>
<!-- 对静态资源不需要进行认证 -->
/images/** = anon
/js/** = anon
/styles/** = anon
<!-- 对所有url都需要进行认证 -->
/logout = logout
/** = authc
</value>
</property>
</bean>
首先看一下Shiro中的web filter过滤器:
默认采用的认证过滤器filter是表单过滤器,默认登录的url是/login(只要没有认证的都会跳转到/login路径下),辅助登录成功url是/first。
默认登录url跳转到的页面是login.jsp如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/tag.jsp"%>
<html>
<head>
<TITLE>药品采购平台</TITLE>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<LINK rel="stylesheet" type="text/css" href="${baseurl}styles/style.css">
<LINK rel="stylesheet" type="text/css" href="${baseurl}styles/login.css">
<LINK rel="stylesheet" type="text/css" href="${baseurl}js/easyui/themes/default/easyui.css">
<LINK rel="stylesheet" type="text/css" href="${baseurl}js/easyui/themes/icon.css">
<STYLE type="text/css">
.btnalink {
cursor: hand;
display: block;
width: 80px;
height: 29px;
float: left;
margin: 12px 28px 12px auto;
line-height: 30px;
background: url('${baseurl}images/login/btnbg.jpg') no-repeat;
font-size: 14px;
color: #fff;
font-weight: bold;
text-decoration: none;
}
</STYLE>
<%@ include file="/WEB-INF/jsp/common_js.jsp"%>
<script type="text/javascript">
//登录提示方法
function loginsubmit() {
$("#loginform").submit();
}
</SCRIPT>
</HEAD>
<BODY style="background: #f6fdff url(${baseurl}images/login/bg1.jpg) repeat-x;">
<FORM id="loginform" name