1. 添加Spring的SectionGroup
None.gif<sectionGroup name="spring">
None.gif
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
None.gif
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
None.gif
</sectionGroup>
2. 添加HttpHandler配置
None.gif<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
3. 添加HttpModule配置(如果不添加的话,会有异常)
None.gif<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
4. 最后配置如何依赖注入
None.gif<spring>
None.gif
<context>
None.gif
<resource uri="config://spring/objects"/>
None.gif
</context>
None.gif
<objects xmlns="http://www.springframework.net">
None.gif
<object type="Default.aspx">
None.gif
<property name="Service" ref="myService"/>
None.gif
</object>
None.gif
<object id="myService" type="Services.MyService, Services">
None.gif
</object>
None.gif
</objects>
None.gif
</spring>
object的type属性表明你要对哪个页面进行注入,property的name属性是该页面中被注入的Property的名字,ref就指向了你想注入的实际类型。
注意:1)在节点<context type="Spring.Context.Support.XmlApplicationContext,Spring.Core">不能有这样的配置
2)假如存在aa文件下有个页面test.aspx,则type="~/aa/test.aspx"