Study Notes 42_springmvc

Source: Internet
Author: User

In Springmvc, Global.axas changes, which

1. It turned out to be

public class MvcApplication:System.web.HttpApplication

is now

public class MvcApplication:Spring.web.Mvc.SpringMvcApplication

In Web. config, changes have also occurred:



<sectiongroup name= "Spring" >

<section name= "Context" type= ",spring.web.mvc4" >




3. In the Web. config, you also need to have


<spring>//and <configsections> Peers


<resource uri = "File://~/config/BLL.xml" >//here is the configuration of the business logic, because in Controllers.xml,

<resource uri= "File://~/config/controllers.xml" >//here is to let the UI project, there must be a config folder inside, place the Controllers.xml file, to configure the type




4. In <controllers.xml>, configure the Controller

If there is a BLL class attribute in the controller to run the business logic, then the configuration file can be used to replace the BLL class instance, but the attribute must be written as an interface reference

<?xml version= "1.0" encoding= "Utf-8" >


<object type= "Class full name, assembly name" singletion= "false" (the default is True, indicates a single column, to be remembered instead of false) >

<property name= "BLL" ref= "XXXBLL"/>//xxxbll points to Bll.xml in XXXBLL



4.1 In the Bll.xml

<?xml version= "1.0" encoding= "Utf-8" >


<object name= "XXXBLL" Type= "class full name, assembly name" singletion= "false" ></...>


The effect is that the properties of the BLL class in the controller do not seem to be assigned at all. That Controller.xml,bll.xml,dal.xml, and Global.axas inherited the springmvcapplication synthesis results

Spring is a way to penetrate every level, just not in the UI layer, using

Iapplicationcontext CTX = Contextregistry.getcontext ();

CTx. GetObject () to create the instance.

There is no need to use spring in the UI layer, or the project is expected to be a future business, or the database changes little, can not be used.

Study Notes 42_springmvc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.