2013-01-02 33 views
1

我對我的DI使用了Spring。 有沒有相當於@ManagedProperty?我想將一個視圖scoped bean的值注入下一頁的另一個視圖。@ManagedProperty在Spring中相當於

e.g

@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; 
} 

回答

1

@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

+0

我相信,這將實例化一個新的Page1Bean..I要連同它的所有內容實際Page1Bean通過。 –

+0

我一直在使用@注入..我認爲這是JEE版本。 –

+0

用於將jsf視圖範圍移植到spring:http://cagataycivici.wordpress.com/2010/02/17/port-jsf-2-0s-viewscope-to-spring-3-0/ – digitaljoel

相關問題