I am using Spring for my DI. Is there an equivalent of @ManagedProperty? I want to inject the value from one view scoped bean into another one on the next page.
eg
@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
or @Autowired
should work. @Resource
is the Java EE implementation, @Autowired
is the spring specific annotation. I can't find the reference now, but it seems like I read once to prefer @Resource
over @Autowired
.
here's a blog post I found that talks about @Inject
vs. @Resource
vs. @Autowired
http://blogs.sourceallies.com/2011/08/spring-injection-with-resource-and-autowired/#more-2350
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.