1. Controller
@Autowired
ServletContext sc;
test t = new test();
t.test(sc);
2. JAVA
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.servlet.FrameworkServlet;
import javax.servlet.ServletContext;
import java.util.HashMap;
public class test {
public void test(ServletContext sc) throws Exception {
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(sc, FrameworkServlet.SERVLET_CONTEXT_PREFIX + "dispatcherServlet");
TESTDAO testDAO= (TESTDAO ) wac.getBean("testDAO");
HashMap hs = testDAO.test();
}
}
0 개의 댓글:
댓글 쓰기