springmvc搭建的项目,dao、service、controller都是采用注解的方式,在servlet中获取service的方法(见代码):
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
INewsAttachService newsAttachService = (INewsAttachService) context.getBean("newsAttachService");
NewsAttach attach = new NewsAttach();
attach.setAttach_Name(item.getName());
attach.setAttach_real_path(uploadFileName);
attach.setResource_id(r_id);
attach.setAttach_path(attachUploadPath+"/"+saveFileName);
newsAttachService.save(attach);