servlet 中获取 spring 管理的 bean
来源:互联网 发布:126邮箱ssl端口号 编辑:程序博客网 时间:2024/05/18 01:01
package spring.servlets;import java.io.IOException;import javax.servlet.ServletContext;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.web.context.WebApplicationContext;import org.springframework.web.context.support.WebApplicationContextUtils;import spring.beans.User;import spring.services.UserServices;@WebServlet("/UserServlet")public class UserServlet extends HttpServlet {private static final long serialVersionUID = 1L;private UserServices userServices;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//获取ServletContext 再获取 WebApplicationContextUtilsServletContext servletContext = this.getServletContext();WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);userServices = (UserServices) context.getBean("userServices");System.out.println("--------------------------");User u = userServices.getUser();System.out.println(u.getUserName());System.out.println(u.getPassword());System.out.println("--------------------------");}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {this.doGet(request, response);}}
4 0
- servlet 中获取 spring 管理的 bean
- servlet中获取spring管理的bean
- servlet 中获取 spring 管理的 bean
- 在servlet中获取spring管理的bean
- Servlet中获取spring bean的管理对象
- 在Servlet中获取spring管理的bean
- Servlet获取Spring管理的Bean
- Servlet中调用Spring管理的Bean
- servlet中手动获取spring的bean
- Servlet中访问spring容器管理的bean
- 在Servlet中获取Spring的指定bean
- Filter或Servlet中获取Spring Bean的方法
- 获取spring管理的bean
- 在servlet中获取spring Bean对象
- Servlet,Webservice中spring 获取Bean方式
- Servlet获取Spring bean
- 在jsp页面中获取Spring管理的Bean
- Spring动态获取IoC容器中管理的Bean
- 简单抽奖软件java程序设计
- 使用 spring web 时候 web.xml 的配置
- MapReduce实例——ChainMapper的使用
- UFLDL学习笔记2(Preprocessing: PCA and Whitening)
- JavaScript前台判空
- servlet 中获取 spring 管理的 bean
- 2D斜视角游戏的绘制次序总结(云风的blog)
- 开发工作中使用的敏捷开发模式
- qt-connect
- 全球电信运营商排名中国移动利润仍为第一
- Android 技巧 - 自动生成 Action Bar Theme
- MFC、ATL窗口消息封装机制对比分析
- j2ee web 命名习惯
- python 文件