2011-01-18 15 views
2

@Autowireを使用せずに注釈コントローラ(@Controller)にハンドラを挿入するにはどうすればよいですか?注釈コントローラにハンドラを挿入する

+0

'*がハンドラです* - あなたが参照していますか? – skaffman

+0

私はすべてのビジネスロジックを 'ハンドラ'クラスに入れ、必要に応じてコントローラに注入します。ハンドラクラスの理解はどうですか? :) – Koolala

答えて

2

もちろん、常にXMLにオートワイヤリングを設定することができます。

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    default-autowire="byType"> 

    <!-- all beans here will be autowired, including those 
     found by <contect:component-scan /> --> 

</beans> 

しかし、あなたはおそらくプロパティのセッターメソッドを提供する必要があります。

参考:ところでAutowiring Collaborators


、あなたも(そしてもちろんのJSR-330の@Inject、感謝@Bozho)使用したくない場合はSpringのJSR-250 @Resourceのアノテーションを使用することができます独自の@Autowired注釈。

参考:Controller`クラス@@Resource@Autowired and @Inject

+0

また '@Iject' – Bozho

+0

ありがとう:)私は@リソースを使用しました... – Koolala

関連する問題