第一步当然是导包啦
拷贝shiroFilter配置到web.xml
拷贝shiro Spring配置文件并集成到Spring
applicationContext.xml 改名为applicationContext-shiro.xml并在applicationContext.xml中导入
修改配置文件
applicationContext-shiro.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- shiro的核心-->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<!-- 引入认证 -->
<property name="realm" ref="myRealm"></property>
</bean>
<bean id="myRealm" class="cn.itsource.shiro.realms.MyRealm">
<!-- 设置shiro身份认证的比较器 -->
<property name="credentialsMatcher">
<bean class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
<property name="hashAlgorithmName" value="MD5"></property>
<property name="hashIterations" value="913"></property>
</bean>
</property>
</bean>
<!-- shiro的过滤器的相关配置 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager" />
<property name="loginUrl" value="/login.jsp" />
<property name="successUrl" value="/main.jsp" />
<property name="unauthorizedUrl" value="/unauthorized.jsp" />
<!-- 过滤器的配置 -->
<property name="filterChainDefinitionM