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>

  • 相关阅读:
    HDOJ 4259 Double Dealing
    第三课 MongoDB 数据更新
    百度语音识别API初探
    几种常见排序算法的java实现
    HDU 1051 Wooden Sticks 贪心题解
    离线安装Cloudera Manager5.3.4与CDH5.3.4
    Unix哲学
    如何在管理层变动中存活下来
    SWTError: No more handles [gtk_init_check() failed] running platform tests (on Linux)
    "xxadmin" user: No protocol specified 错误
  • 原文地址:https://www.cnblogs.com/smthts/p/2687740.html
Copyright © 2011-2022 走看看