context-properties.xml 활용
- 작성자 :
- 이*
- 작성일 :
- 2009-12-05 12:05:43
- 조회수 :
- 4,976
- 구분 :
- 실행환경
- 진행상태 :
- 완료
Q
context-properties.xml 등록된 내용을
시스템 내의 util 메소드에서 사용하고 싶습니다.
import egovframework.rte.fdl.property.EgovPropertyService;
public class ImageServlet extends HttpServlet {
/** EgovPropertyService */
@Resource(name = "propertiesService")
protected EgovPropertyService propertiesService;
String filename = propertiesService.getString("ImgUrl");
}
대충 이렇게 했는데 실행을 하면 null 값으로 처리가 되지 않습니다.
context-properties.xml 값을 control/impl/dao 밖에서 사용을 할 수 없나요?
시스템 내의 util 메소드에서 사용하고 싶습니다.
import egovframework.rte.fdl.property.EgovPropertyService;
public class ImageServlet extends HttpServlet {
/** EgovPropertyService */
@Resource(name = "propertiesService")
protected EgovPropertyService propertiesService;
String filename = propertiesService.getString("ImgUrl");
}
대충 이렇게 했는데 실행을 하면 null 값으로 처리가 되지 않습니다.
context-properties.xml 값을 control/impl/dao 밖에서 사용을 할 수 없나요?
A
안녕하세요.. 이솔님..
위와 같이 별도로 Servlet을 만들어 사용하시는 경우는 annotation에 의한 설정이 처리되지 않기 때문에 사용하실 수 없을 것 같습니다.
다시 말씀드리면.. 쓰신 것처럼.. control/impl/dao (@Controller, @Service, @Repository)만 사용가능합니다.
이유는 위 3개의 annotation을 component-scan에 의해 spring bean으로 등록될 때에 @Resource 등이 injection되기 때문에 사용가능합니다.
위의 경우는 component-scan과 같은 방식으로 spring bean에 등록되지 않기 때문에 @Resource 부분이 injection되지 않기 때문엥... propertiesService 자체가 null로 남아 있는 것입니다..
그럼.. 즐거운 하루되십시오.
감사합니다.
위와 같이 별도로 Servlet을 만들어 사용하시는 경우는 annotation에 의한 설정이 처리되지 않기 때문에 사용하실 수 없을 것 같습니다.
다시 말씀드리면.. 쓰신 것처럼.. control/impl/dao (@Controller, @Service, @Repository)만 사용가능합니다.
이유는 위 3개의 annotation을 component-scan에 의해 spring bean으로 등록될 때에 @Resource 등이 injection되기 때문에 사용가능합니다.
위의 경우는 component-scan과 같은 방식으로 spring bean에 등록되지 않기 때문에 @Resource 부분이 injection되지 않기 때문엥... propertiesService 자체가 null로 남아 있는 것입니다..
그럼.. 즐거운 하루되십시오.
감사합니다.