1 16 17 package org.springframework.web.context.support; 18 19 import java.io.IOException ; 20 21 import javax.servlet.ServletException ; 22 import javax.servlet.http.HttpServlet ; 23 import javax.servlet.http.HttpServletRequest ; 24 import javax.servlet.http.HttpServletResponse ; 25 26 import org.springframework.web.HttpRequestHandler; 27 import org.springframework.web.context.WebApplicationContext; 28 29 45 public class HttpRequestHandlerServlet extends HttpServlet { 46 47 private HttpRequestHandler target; 48 49 50 public void init() throws ServletException { 51 WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); 52 this.target = (HttpRequestHandler) wac.getBean(getServletName(), HttpRequestHandler.class); 53 } 54 55 56 protected void service(HttpServletRequest request, HttpServletResponse response) 57 throws ServletException , IOException { 58 59 this.target.handleRequest(request, response); 60 } 61 62 } 63 | Popular Tags |