项目使用Spring.NET+NHibernate+MVC来设计
为了方便起见,我的配置文件独立来写 spring.xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!--Spring.net配置-->
<sectionGroup name="Spring">
<section name="context" type="Spring.Context.Support.MvcContextHandler,Spring.Web.Mvc"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
</sectionGroup>
<section name="databaseSettings" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
<spring>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>
<parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data"/>
</parsers>
<context>
<resource uri="~/Config/Controll.cfg.xml" /> //Controller注入的配置文件
</context>
</spring>
<!--数据库连接字符串-->
<databaseSettings>
<add key="db.datasource" value="XP-201012041749\SQLEXPRESS" />
<add key="db.user" value="sa" />
<add key="db.password" value="webadmin" />
<add key="db.database" value="WebDB" />
</databaseSettings>
</configuration>
现在是如何使用这个配置文件 spring.xml