zoukankan      html  css  js  c++  java
  • 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初步设置完成啦 






  • 相关阅读:
    自动化测试先关
    hadoop集群(第二节机器信息分布表)
    hadoop集群(第一节)
    SpringCloud微服务架构学习笔记
    SpringBoot启动一个项目
    VUE框架介绍
    SpringMVC配置与使用
    Spring学习笔记(二)
    8、XML与JSON
    7、主页面访问权限控制
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3000861.html
Copyright © 2011-2022 走看看