HttpSession session = request.getSession();
IUserDao ud=(IUserDao)this.getObjectFromApplication(session.getServletContext(), "IUserDao");
After execution, ud can directly call the method in it
/**
* Get an instance of the Spring container through WebApplicationContextUtils. Returns an instance of the bean based on the bean's name.
* @param servletContext : ServletContext context.
* @param beanName : The name of the bean in the Spring container to be obtained.
* @return returns an instance of the Bean.
*/
private Object getObjectFromApplication(ServletContext servletContext,String beanName){
//Get an instance of the Spring container through WebApplicationContextUtils.
ApplicationContext application=WebApplicationContextUtils.getWebApplicationContext(servletContext);
//Return the instance of Bean.
return application.getBean(beanName);
}