版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_30553235/article/details/74971414
我使用的是jeecmsV8版本。
1.修改web.xml(/jeecms/WebContent/WEB-INF/web.xml)
修改JeeCmsAdmin这个servlet,把/jeeadmin/jeecms/*替换成你想要的后台访问路径。
注:此处替换的路径必须为三层或四层,否则会报错。(你可以去修改源码)
-
/*
-
* 获得第三个路径分隔符的位置
-
*
-
* @param request
-
* @throws IllegalStateException
-
* 访问路径错误,没有三(四)个'/'
-
*/
-
private static String getURI(HttpServletRequest request)
-
throws IllegalStateException {
-
UrlPathHelper helper = new UrlPathHelper();
-
String uri = helper.getOriginatingRequestUri(request);
-
String ctxPath = helper.getOriginatingContextPath(request);
-
int start = 0, i = 0, count = 2;
-
if (!StringUtils.isBlank(ctxPath)) {
-
count++;
-
}
-
while (i < count && start != -1) {
-
start = uri.indexOf('/', start + 1);
-
i++;
-
}
-
-
if (start <= 0) {
-
throw new IllegalStateException(
-
"admin access path not like '/jeeadmin/jeecms/...' pattern: "
-
+ uri);
-
}
-
return uri.substring(start);
-
}
2.修改shiro配置文件(/jeecms/WebContent/WEB-INF/config/shiro-context.xml)
把shiro-context.xml配置文件里面的/jeeadmin/jeecms全部替换成你自己设置的后台访问路径 , 要和web.xml里设置的保持一致
shiro-context.xml中红色部分替换掉
-
-
<beans xmlns="http://www.springframework.org/schema/beans"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
-
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
-
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd"
-
default-lazy-init="true">
-
-
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
-
<property name="securityManager" ref="securityManager" />
-
<property name="loginUrl" value="/login.jspx" />
-
<property name="successUrl" value="/" />
-
<property name="filters">
-
<util:map>
-
<entry key="authc" value-ref="authcFilter" />
-
<entry key="user" value-ref="userFilter" />
-
<entry key="logout" value-ref="logoutFilter" />
-
</util:map>
-
</property>
-
<!--anon匿名 authc登录认证 user用户已登录 logout退出filter-->
-
<property name="filterChainDefinitions">
-
<value>
-
*.jspx = anon
-
*.jhtml = anon
-
/member/forgot_password.jspx = anon
-
/member/password_reset.jspx = anon
-
/member/jobapply.jspx = anon
-
/login.jspx = authc
-
/logout.jspx = logout
-
/member/** = user
-
/jeeadmin/jeecms/login.do = authc
-
/jeeadmin/jeecms/logout.do = logout
-
/jeeadmin/jeecms/** =user
-
</value>
-
</property>
-
</bean>
-
<!-- Shiro Filter -->
-
<bean id="adminUrlBean" class="com.jeecms.core.security.CmsAdminUrl">
-
<property name="adminLogin" value="/jeeadmin/jeecms/login.do"/>
-
<property name="adminPrefix" value="/jeeadmin/jeecms/"/>
-
</bean>
-
<bean id="authcFilter" class="com.jeecms.core.security.CmsAuthenticationFilter" parent="adminUrlBean">
-
<property name="adminIndex" value="/jeeadmin/jeecms/index.do"/>
-
</bean>
-
<bean id="userFilter" class="com.jeecms.core.security.CmsUserFilter" parent="adminUrlBean"/>
-
<bean id="logoutFilter" class="com.jeecms.core.security.CmsLogoutFilter" parent="adminUrlBean"/>
-
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
-
<property name="cacheManager" ref="shiroEhcacheManager"/>
-
<property name="rememberMeManager" ref="rememberMeManager"/>
-
<property name="realm" ref="authorizingRealm" />
-
</bean>
-
<bean id="authorizingRealm" class="com.jeecms.core.security.CmsAuthorizingRealm">
-
<property name="credentialsMatcher">
-
<bean class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
-
<property name="hashAlgorithmName" value="MD5"/>
-
<!-- true means hex encoded, false means base64 encoded -->
-
<property name="storedCredentialsHexEncoded" value="true"/>
-
<!-- 迭代次数 -->
-
<property name="hashIterations" value="1" />
-
</bean>
-
</property>
-
<property name="cmsUserMng" ref="cmsUserMng" />
-
</bean>
-
<bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
-
<!--
-
<property name="cacheManagerConfigFile">
-
<value>classpath:ehcache-shiro.xml</value>
-
</property>
-
-->
-
<property name="cacheManager">
-
<ref local="cacheManager"/>
-
</property>
-
</bean>
-
<bean id="rememberMeCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
-
<constructor-arg value="rememberMe"/>
-
<property name="httpOnly" value="true"/>
-
<property name="maxAge" value="31536000"/><!-- 365天 -->
-
</bean>
-
<!-- rememberMe管理器 -->
-
<bean id="rememberMeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager">
-
<property name="cipherKey" value="#{T(org.apache.shiro.codec.Base64).decode('4AvVhmFLUs0KTA3Kprsdag==')}"/>
-
<property name="cookie" ref="rememberMeCookie"/>
-
</bean>
-
<!-- Enable Shiro Annotations for Spring-configured beans. Only run after -->
-
<!-- the lifecycleBeanProcessor has run: -->
-
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
-
</beans>
到此,搞定!
个人理解,如有错误之处,还望各位指出.