public class UploadSevlet extends HttpServlet {
private static final long serialVersionUID = 4738756696822806899L;
private UserService userService;
public void init(ServletConfig config) {
//spring获取注解
WebApplicationContext wac = WebApplicationContextUtils
.getRequiredWebApplicationContext(config.getServletContext());
userService = (UserService) wac.getBean("userService");
}
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
转载于:https://my.oschina.net/u/1049094/blog/520549