5

SpringMvc怎么把web.xml配置换成java配置

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
<!--             classpath:db.properties -->
<!--             classpath:main-config.xml -->
<!--             classpath:config/fweb-archetype-mvc.xml -->
            classpath:config/fweb-shiro-mvc.xml
        </param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <filter>
        <filter-name>shiroFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <!-- 设置true由servlet容器控制filter的生命周期 -->
        <init-param>
            <param-name>targetFilterLifecycle</param-name>
            <param-value>true</param-value>
        </init-param>
        <!-- 设置spring容器filter的bean id,如果不设置则找与filter-name一致的bean-->
        <init-param>
            <param-name>targetBeanName</param-name> 
            <param-value>shiroFilter</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>shiroFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

把上面的配置全部通过java方式配置要如何写

查看全部
qq_29297291
qq_29297291
2019/04/11 17:58
  • spring
  • tomcat
  • eclipse
  • 点赞
  • 收藏
  • 回答
    私信

3个回复