개발/java

jsp에서 service 가져오기

lovelytney 2023. 5. 3. 16:11
반응형

<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.support.WebApplicationContextUtils"%>
<%@page import="com.test.biz.service.TestService"%>

WebApplicationContextUtils.getWebApplicationContext(((HttpServletRequest) request).getSession().getServletContext());

//tomcat
//ServletContext servletContext = getServletContext();

//weblogic
ServletContext servletContext = pageContext.getServletContext();

WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

//서비스호출
TestService testService = (TestService)wac.getBean("testService");
//testService.testList();

반응형