1、案例
@Scope("prototype")
@Controller
public class OrderBomImportController extends DefaultController {
@Autowired
public OrderBomImportService orderBomImportService;
public void forwardEdit() {
String id = (String) getPageData().getParams().get("id");
String type = (String) getPageData().getParams().get("mode");
addParameter("type", type);
}
}
2、分类
singleton(单例)、
prototype(非单例,每一次请求都会产生一个新的bean)、
session(每一次HTTP请求都会产生一个新的bean,同时该bean只在当前HTTP session内有效)、
global session(web会自动当成session类型来使用)、
request(每一次HTTP请求都会产生一个新的bean,同时该bean仅在当前HTTP request内有效)
3、使用
默认为单例,通过设置注解scope prototype 可设置为非单例