zoukankan      html  css  js  c++  java
  • mvc3结合spring.net-依赖注入


    namespace
    Tuzi.Models.IService { public interface IPersonService { string say(string words); }      

     

    namespace Tuzi.Models.Service
    {
        public class PersonService:IPersonService
        {
            public string say(string words)
            {
                return words;
            }
        }
    }

     

    namespace Tuzi.Controllers
    {
        public class TuziController : Controller
        {
            //
            // GET: /Tuzi/
            IPersonService PersonService { get; set; }
            public string msg { get; set; }
            public ActionResult Index()
            {
                return Content(PersonService.say("spring.net和mvc3") + msg);
            }
    
        }
    }
    <?xml version="1.0" encoding="utf-8" ?>
    <objects xmlns="http://www.springframework.net">
      <object type="Tuzi.Controllers.TuziController,Tuzi" singleton="false">
        <property name="Msg" value="msginfo" />
        <property name="PersonService" ref="PersonServiceObj" />
      </object>
      <object id="PersonServiceObj" type="Tuzi.Models.Service.PersonService,Tuzi" >
      </object>
    </objects>
     
      <configSections>
        <!--spring对象和上下文配置-->
        <sectionGroup name="spring">
          <!--<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
          <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />-->
          <section name="context" type="Spring.Context.Support.MvcContextHandler, Spring.Web.Mvc3"/>
        </sectionGroup>
      </configSections>
     <!--spring配置 begin--> 
      <spring>
        <context> 
          <resource uri="file://~/Config/Controllers.xml"/> 
        </context>
     
      </spring>
    Global.asax文件 修改MvcApplication : Spring.Web.Mvc.SpringMvcApplication

    在写配置文件时,默认是没有提示的,将spring.net doc下所有的.xsd复制到以下目录里就行了

     Spring.net强大的功能,简化企业开发。

  • 相关阅读:
    论文阅读 | Spatial Transformer Networks
    Latex的各种帽子
    SiamFC网络影响
    Faster RCNN Tensorflow在测试时得到的result.txt文件
    ubuntu16.04使用docker部署TFserving之安装docker
    ubuntu系统使用Faster RCNN训练自己的数据集
    pandas基础1数据结构介绍
    numpy基础4线性代数等
    numpy基础3通用函数等
    numpy基础2索引和切片
  • 原文地址:https://www.cnblogs.com/zjflove/p/3502529.html
Copyright © 2011-2022 走看看