spring引文之@Autowired
spring注解之@Autowired
最近发现了一个非常好用的spring的注解@Autowired,请看我写的一个代码示例:
@Controller @Scope("prototype") public class LoginAction extends ActionSupport{ @Autowired private LoginService loginService; private String uname; public String getUname() { return uname; } public void setUname(String uname) { this.uname = uname; } public String add(){ uname = loginService.add(); System.out.println("ok"); return "add_ok"; } }
使用@Autowired注解之后,当我们需要注入什么属性的时候,就不再需要生成get方法和set方法了,真正的实现了“零注解”的方式,真是太NB了!!!!!!!!!!!!!!