Single and multi-instance management of SPRINGMVC controller

Source: Internet
Author: User

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

When using Spring3 for bean management of controller controllers, if the controller is to be managed in a single case.

There are two ways to configure a multiple-case pattern:

1.springXML2. The controller class of the annotations themselves [Java]View Plaincopyprint?
  1. @Controller
  2. @Scope ("prototype")
  3. Public class Hellocontorller {
  4. private int index=0;
  5. Logger Logger=logger.getlogger (Hellocontorller.   Class.getname ());
  6. //hello World Example
  7. @RequestMapping (value="/hello")
  8. Public String Hello () {
  9. Logger.info ("Spring MVC Hello world!"  +index++);
  10. return "Hello";
  11. }
  12. }


One of the puzzles here is that when the index variable is static, the index variable accumulates for each request access, even though it is in multiple cases. So it can be preliminarily concluded that the generation principle of multiple cases is not simply to re-new a controller.



Single and multi-instance management of SPRINGMVC controller

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.