Spring integrates spring MVC

Source: Internet
Author: User

Do you need a Spring consolidation Springmvc?
Do you need to add the Spring IOC container again?
Do I need to configure the Contextloaderlistener in the Web. xml file to start the Spring IOC container?

1. Required: Typically, similar to data sources, transactions, and consolidation other frameworks are placed in the Spring configuration file (not in the SPRINGMVC configuration file).
In fact, there are Service and Dao in the IOC container corresponding to the Spring configuration file.
2. Not required: Both are placed in the SPRINGMVC configuration file. You can also divide multiple Spring profiles and import other profiles using the import node

Problem: If Spring's IOC container and SPRINGMVC's IOC container have a coincident portion of the packet scanned, it will cause some beans to be created 2 times.
Solve:
1. The package scanned by the Spring IOC container and the SPRINGMVC IOC container have no coincident parts.
2. Use Exclude-filter and Include-filter subnodes to specify annotations that can only be scanned

The beans in the Springmvc IOC container can refer to beans in the Spring IOC container.
Return to it? Conversely, it is not. The beans in the Spring IOC container cannot refer to the bean! in the SPRINGMVC IOC container

Spring integrates spring MVC

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: info-contact@alibabacloud.com 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.