import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Created by Administrator on 14-4-9.
*
* @author leizhimin 14-4-9 上午10:55
*/
@Controller
@RequestMapping("/demo/lsh/ch5")
@Scope("prototype")
public class MultViewController {
private static int st = 0; //静态的
private int index = 0; //非静态
static{
System.out.println("if i apear first, i am single");
}
@RequestMapping("/test")
public String test() {
System.out.println(st++ + " | " + index++);
return "/lsh/ch5/test";
}
}
如果spring--bean是单例,那么web项目一启动就会加载到内存,如果bean是多例,项目会在刚刚使用的时候,就是走到这个请求地址的时候,类才会加载
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Created by Administrator on 14-4-9.
*
* @author leizhimin 14-4-9 上午10:55
*/
@Controller
@RequestMapping("/demo/lsh/ch5")
@Scope("prototype")
public class MultViewController {
private static int st = 0; //静态的
private int index = 0; //非静态
static{
System.out.println("if i apear first, i am single");
}
@RequestMapping("/test")
public String test() {
System.out.println(st++ + " | " + index++);
return "/lsh/ch5/test";
}
}
如果spring--bean是单例,那么web项目一启动就会加载到内存,如果bean是多例,项目会在刚刚使用的时候,就是走到这个请求地址的时候,类才会加载