spring注入servlet

private static WebApplicationContext context;

@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub	
	}
@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
public Object findBean(String beanName) {
		if (context == null) {
			context = WebApplicationContextUtils
					.getRequiredWebApplicationContext(getServletContext());
		}
		return context.getBean(beanName);
	}

 

 

你可能感兴趣的:(spring,servlet)