[Spring] jsp에서 bean 호출하기
개발/Java2010. 2. 8. 18:27
ServletContext ctx = pageContext.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(ctx);
NoticeService noticeServie = (NoticeService)wac.getBean("noticeService");
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(ctx);
NoticeService noticeServie = (NoticeService)wac.getBean("noticeService");
그외..
ApplicationContext
String[] configLocation = new String[]{"config/applicationContext.xml",
"confg/mvc-applicationContext.xml" };
ApplicationContext context = new ClassPathXmlApplicationContext(configLocation);
AccessHistoryService accessHistoryService = (AccessHistoryService)context.getBean("accessHistoryService");
BeanFactory
Resource r = new FileSystemResource("/WEB-INF/conf/applicationContext.xml");
//Resource r = new ClassPathResource("conf/applicationContext.xml");
BeanFactory f = new XmlBeanFactory(r);
AccessHistoryService accessHistoryService = (AccessHistoryService)f.getBean("accessHistoryService");
'개발 > Java' 카테고리의 다른 글
Spring MVC Annotation기반으로 사용시 URL기반 요청 문제점 해결방법 (0) | 2010.05.25 |
---|---|
[ibatis] iBATIS 2.3.4.726 - PreparedStatement - ? 바인딩 로그 처리 (0) | 2010.03.05 |
Spring - Java/J2EE Application FrameworkVersion 1.2.2 (0) | 2010.02.04 |
Tip. MessageFormat 예제 (0) | 2010.01.07 |
[java] Properties 읽고 쓰기 (0) | 2009.12.04 |