• Spring Setting


    Spring 会 根据版本不同所要求的 lib 都不一样。。 请认真确认下

    建完project  第一个要看的就是 web.xml


    红色字体:  file名 根据不同请自行变动 

    褐色字体: 变数名 可以有不同

    紫色字体: controller 接近ext

    灰色底部: 我的spring是 3.0.7relase 如果你的lib 不一样这里也会有所不同 请注意


    前奏: 自行下载所需lib http://www.springsource.org/download/community


    第一步 驱动tomcat时要读的file 写上  ==> 位置 web.xml

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/conf/applicationContext.xml</param-value> 
    </context-param>
      
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


    第二步 Controller 接近方式 ==> 位置 web.xml

    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
     /WEB-INF/conf/action-servlet.xml
    </param-value>
     </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>
      

    第三步 contextConfigLocation  位置 ==>  /WEB-INF/conf/applicationContext.xml ( 有关spring 设置的 就在这里设置了)

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        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
             http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
             http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
    >
     
        
        <!-- 内容可以没有 -->
    </beans>


    第四步 action 位置 => /WEB-INF/conf/action-servlet.xml ( 有关 controller 就在这里设置了)


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
    >
      
       <context:component-scan base-package="main">
           <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>

    </beans>


    运行tomcat  如果没有error  恭喜你 spring初步设置完成啦 






  • 相关阅读:
    python pytest全局用例共用之conftest.py详解
    mybatis mapper文件中select标签参数汇总
    mybatis整合redis实现二级缓存(转载)
    代码智能---aiXcoder插件
    mybatis运行原理及源码流程分析
    linux关闭防火墙
    mysql 锁
    mysql 性能低下的分析
    针对msyql的like中 两边都不得不使用% 的场景分析
    mysql 相关文件路径、配置
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3000861.html
Copyright © 2020-2023  润新知