2011-01-18 3 views
2

@Autowire을 사용하지 않고 특수 효과 컨트롤러 (@Controller)에 처리기를 주입하려면 어떻게해야합니까?특수 효과 컨트롤러에 처리기 삽입

+0

'는 * 핸들러입니다 * - 당신이 언급하는거야? – skaffman

+0

글쎄, 모든 비즈니스 로직을 'handler'클래스에 넣고 필요에 따라 컨트롤러에 주입합니다. 'handler'클래스에 대한 이해는 무엇입니까? :) – Koolala

답변

2

당신은 물론 항상 XML에에서 autowiring을 구성 할 수 있습니다

<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> 

그러나 당신은 아마 속성에 대한 setter 메소드를 제공해야합니다.

참조 : BTWAutowiring Collaborators


, 당신은 또한 (물론 JSR-330의 @Inject, 감사 @Bozho) 사용하지 않으려면 봄 년대 JSR-250 @Resource 주석을 사용 할 수 있습니다 독점적 인 @Autowired 주석.

참조 : Controller` 클래스 @@Resource, @Autowired and @Inject

+0

그리고'@ Inject' – Bozho

+0

고마워요 :) @Resource를 사용했습니다 ... – Koolala

관련 문제