第一步在JSP页面中导入下面的包:

<%@page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@page import="org.springframework.web.context.WebApplicationContext" %>

第二步:获取实例

 WebApplicationContext context=WebApplicationContextUtils.getWebApplicationContext(application);
User user = (User)context.getBean("user");

完成~~~

05-11 22:55