Spring MVC 在JSP中获取service
在Controller、Service层都已经配置好了自动注入,但是在JSP中直接使用
IuserInfoShService uishService = new IuserInfoShService();
会出现空指针,我们需要借助WebApplicationContextUtils工具类获取 WebApplicationContext获取spring注入的Bean
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
IuserInfoShService uishService = (IuserInfoShService)wac.getBean("uishService");//注入Bean的名称
就可以进行相关的操作了