[英]@ManagedProperty equivalent in Spring
我将Spring用于我的DI。 是否有@ManagedProperty的等效项? 我想将值从一个视图作用域的bean注入到下一页的另一个视图中。
例如
@Component
@Scope("view")
public class Page1Bean(){
private String value;
}
@Component
@Scope("view")
public class Page2Bean(){
@ManagedProperty(value = #{page1Bean}") //doesnt work in Spring
private Page1Bean bean;
}
@Resource
或@Autowired
应该可以工作。 @Resource
是Java EE实现,@ @Autowired
是spring特定的注释。 我现在找不到引用,但似乎我读过一次,所以喜欢@Resource
不是@Autowired
。
这是我发现的一篇博客文章,内容涉及@Inject
与@Resource
与@Autowired
http://blogs.sourceallies.com/2011/08/spring-injection-with-resource-and-autowired/#more-2350
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.