@Scope("prototype")
spring 默認scope 是單例模式
scope="prototype" 能夠保證 當有請求的時候 都建立一個Action對象.web
例子:spring
@Scope("prototype") @Controller @RequestMapping("/web/login") public class LoginWebController { //private static final Logger logger = Logger.getLogger(LoginWebController.class); @Resource(name = "loginService") private LoginService loginServiceImpl; ..
@Resourceapp
用來裝配bean,獲取bean的,就像是Android中的Butterknife獲取頁面的組件實例。spa
例子prototype
@Resource(name = "loginService") private LoginService loginServiceImpl;