• jeecms 修改后台访问路径


     

     版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_30553235/article/details/74971414

        我使用的是jeecmsV8版本。

       
    1.修改web.xml(/jeecms/WebContent/WEB-INF/web.xml)

        修改JeeCmsAdmin这个servlet,把/jeeadmin/jeecms/*替换成你想要的后台访问路径。

        注:此处替换的路径必须为三层或四层,否则会报错。(你可以去修改源码)

     

    1.  
      /*
    2.  
      * 获得第三个路径分隔符的位置
    3.  
      *
    4.  
      * @param request
    5.  
      * @throws IllegalStateException
    6.  
      * 访问路径错误,没有三(四)个'/'
    7.  
      */
    8.  
      private static String getURI(HttpServletRequest request)
    9.  
      throws IllegalStateException {
    10.  
      UrlPathHelper helper = new UrlPathHelper();
    11.  
      String uri = helper.getOriginatingRequestUri(request);
    12.  
      String ctxPath = helper.getOriginatingContextPath(request);
    13.  
      int start = 0, i = 0, count = 2;
    14.  
      if (!StringUtils.isBlank(ctxPath)) {
    15.  
      count++;
    16.  
      }
    17.  
      while (i < count && start != -1) {
    18.  
      start = uri.indexOf('/', start + 1);
    19.  
      i++;
    20.  
      }
    21.  
       
    22.  
      if (start <= 0) {
    23.  
      throw new IllegalStateException(
    24.  
      "admin access path not like '/jeeadmin/jeecms/...' pattern: "
    25.  
      + uri);
    26.  
      }
    27.  
      return uri.substring(start);
    28.  
      }

    2.修改shiro配置文件(/jeecms/WebContent/WEB-INF/config/shiro-context.xml)

    把shiro-context.xml配置文件里面的/jeeadmin/jeecms全部替换成你自己设置的后台访问路径 , 要和web.xml里设置的保持一致

     

     shiro-context.xml中红色部分替换掉

     

    1.  
      <?xml version="1.0" encoding="UTF-8"?>
    2.  
      <beans xmlns="http://www.springframework.org/schema/beans"
    3.  
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
    4.  
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    5.  
      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd"
    6.  
      default-lazy-init="true">
    7.  
       
    8.  
      <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
    9.  
      <property name="securityManager" ref="securityManager" />
    10.  
      <property name="loginUrl" value="/login.jspx" />
    11.  
      <property name="successUrl" value="/" />
    12.  
      <property name="filters">
    13.  
      <util:map>
    14.  
      <entry key="authc" value-ref="authcFilter" />
    15.  
      <entry key="user" value-ref="userFilter" />
    16.  
      <entry key="logout" value-ref="logoutFilter" />
    17.  
      </util:map>
    18.  
      </property>
    19.  
      <!--anon匿名 authc登录认证 user用户已登录 logout退出filter-->
    20.  
      <property name="filterChainDefinitions">
    21.  
      <value>
    22.  
      *.jspx = anon
    23.  
      *.jhtml = anon
    24.  
      /member/forgot_password.jspx = anon
    25.  
      /member/password_reset.jspx = anon
    26.  
      /member/jobapply.jspx = anon
    27.  
      /login.jspx = authc
    28.  
      /logout.jspx = logout
    29.  
      /member/** = user
    30.  
      /jeeadmin/jeecms/login.do = authc
    31.  
      /jeeadmin/jeecms/logout.do = logout
    32.  
      /jeeadmin/jeecms/** =user
    33.  
      </value>
    34.  
      </property>
    35.  
      </bean>
    36.  
      <!-- Shiro Filter -->
    37.  
      <bean id="adminUrlBean" class="com.jeecms.core.security.CmsAdminUrl">
    38.  
      <property name="adminLogin" value="/jeeadmin/jeecms/login.do"/>
    39.  
      <property name="adminPrefix" value="/jeeadmin/jeecms/"/>
    40.  
      </bean>
    41.  
      <bean id="authcFilter" class="com.jeecms.core.security.CmsAuthenticationFilter" parent="adminUrlBean">
    42.  
      <property name="adminIndex" value="/jeeadmin/jeecms/index.do"/>
    43.  
      </bean>
    44.  
      <bean id="userFilter" class="com.jeecms.core.security.CmsUserFilter" parent="adminUrlBean"/>
    45.  
      <bean id="logoutFilter" class="com.jeecms.core.security.CmsLogoutFilter" parent="adminUrlBean"/>
    46.  
      <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
    47.  
      <property name="cacheManager" ref="shiroEhcacheManager"/>
    48.  
      <property name="rememberMeManager" ref="rememberMeManager"/>
    49.  
      <property name="realm" ref="authorizingRealm" />
    50.  
      </bean>
    51.  
      <bean id="authorizingRealm" class="com.jeecms.core.security.CmsAuthorizingRealm">
    52.  
      <property name="credentialsMatcher">
    53.  
      <bean class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
    54.  
      <property name="hashAlgorithmName" value="MD5"/>
    55.  
      <!-- true means hex encoded, false means base64 encoded -->
    56.  
      <property name="storedCredentialsHexEncoded" value="true"/>
    57.  
      <!-- 迭代次数 -->
    58.  
      <property name="hashIterations" value="1" />
    59.  
      </bean>
    60.  
      </property>
    61.  
      <property name="cmsUserMng" ref="cmsUserMng" />
    62.  
      </bean>
    63.  
      <bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
    64.  
      <!--
    65.  
      <property name="cacheManagerConfigFile">
    66.  
      <value>classpath:ehcache-shiro.xml</value>
    67.  
      </property>
    68.  
      -->
    69.  
      <property name="cacheManager">
    70.  
      <ref local="cacheManager"/>
    71.  
      </property>
    72.  
      </bean>
    73.  
      <bean id="rememberMeCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
    74.  
      <constructor-arg value="rememberMe"/>
    75.  
      <property name="httpOnly" value="true"/>
    76.  
      <property name="maxAge" value="31536000"/><!-- 365天 -->
    77.  
      </bean>
    78.  
      <!-- rememberMe管理器 -->
    79.  
      <bean id="rememberMeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager">
    80.  
      <property name="cipherKey" value="#{T(org.apache.shiro.codec.Base64).decode('4AvVhmFLUs0KTA3Kprsdag==')}"/>
    81.  
      <property name="cookie" ref="rememberMeCookie"/>
    82.  
      </bean>
    83.  
      <!-- Enable Shiro Annotations for Spring-configured beans. Only run after -->
    84.  
      <!-- the lifecycleBeanProcessor has run: -->
    85.  
      <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
    86.  
      </beans>

                                                                                                                                                                                                                                                                    到此,搞定!

                                                                                                                                                                                                                                           个人理解,如有错误之处,还望各位指出.

  • 相关阅读:
    python 表达式
    anaconda jupyter notebook 启动方法
    python3基本数据类型补充
    Python3 基本数据类型
    pycharm 与 anaconda 关联
    31.Android之常用单位px、dip、sp学习
    30.Android之百度地图简单学习
    29.Android之文本框输入自动提示学习
    28.Android之权限请求汇总
    27.Android之ImageView获取图片学习
  • 原文地址:https://www.cnblogs.com/Jeely/p/11214454.html
Copyright © 2020-2023  润新知