zoukankan      html  css  js  c++  java
  • 转Spring.net web.config配置文件(经过整理和修改)

    注:此文只适用于WebForm,Winform中需要将HttpMoudles和HttpHandlers去掉

    转载地址:http://blog.163.com/fengzhisha0914@126/blog/static/15031478520113115718158/

    需要引入:spring.Aop,spring.core,spring.web,antlr.runtime,common.logging

    Web.config配置文件

    1. 添加Spring的SectionGroup

    View Code
    1 <sectionGroup name="spring">
    2       <section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
    3       <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
    4 </sectionGroup>

    2. 添加HttpHandler配置

    View Code
    1 <add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>

    3. 添加HttpModule配置(如果不添加的话,会有异常)---注:此行一定要放到HttpModule的第一条,要不然会有报错,我也不知道为什么???那位大侠可告诉一下

    View Code
    1 <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>

    4. 最后配置如何依赖注入

    View Code
     1 <spring>
     2     <context>
     3       <resource uri="config://spring/objects"/>
     4     </context>
     5     <objects xmlns="http://www.springframework.net">
     6       <object type="Default.aspx">
     7         <property name="Service" ref="myService"/>
     8       </object>
     9       <object id="myService" type="Services.MyService, Services">
    10       </object>
    11     </objects>
    12   </spring>

    上面那个是定义在Web.config中的Spring节点的写法,下面这个更全一点

    <spring>

    <!--

    配置在Web.config中需要指定type

    <context type="Spring.Context.Support.XmlApplicationContext, Spring.Core">

    -->

    <!--配置在其他xml中不需要指定type-->

        <context>

          <!--<resource uri="config://spring/objects"/>(配置在Web.config中方法)-->

          <resource uri="~/spring.xml.config"/><!--指定其他配置文件-->

        </context>

  • 相关阅读:
    元组转换列表
    python切片
    序列类型的方法 增删改查
    python基础 四则运算和数据类型
    linux 常用基础命令操作
    MySQL 命令操作
    linux中如何修改root密码、设置固定IP、安装vmware tools
    虚拟机中网络桥接模式设置
    PHP基础
    HTML基本标签介绍
  • 原文地址:https://www.cnblogs.com/smthts/p/2687740.html
Copyright © 2011-2022 走看看