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?
- @Controller
- @Scope ("prototype")
- Public class Hellocontorller {
- private int index=0;
- Logger Logger=logger.getlogger (Hellocontorller. Class.getname ());
- //hello World Example
- @RequestMapping (value="/hello")
- Public String Hello () {
- Logger.info ("Spring MVC Hello world!" +index++);
- return "Hello";
- }
- }
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