如何在SpringMVC 的@Controller 层中获取bean
来源:互联网 发布:edge网络是什么 编辑:程序博客网 时间:2024/06/10 00:02
import *************************
import *************************
import *************************
@Controller
public class BookController implements ApplicationContextAware {
private WebApplicationContext context;
@Override //这个是ApplicationContextAware 要实现的接口
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context=(WebApplicationContext) applicationContext;
}
@RequestMapping(value="/go.action")
public ModelAndView go(){
ModelAndView mv=new ModelAndView("index");
BookInfoBiz biz=(BookInfoBiz) context.getBean("bookInfoBizImpl"); //然后就这样就可以获取 Spring托管的bean了
List<BookInfo> list=biz.getAllBookInfo(new BookInfo());
mv.addObject("show", list);
for(BookInfo l:list){
System.out.println(l);
}
return mv;//redirect:show.jsp
}
}
0 0
- 如何在SpringMVC 的@Controller 层中获取bean
- springmvc的controller层如何获取到请求的数据
- SpringMVC在Controller层中注入request的坑
- SpringMVC在Controller层中注入request的坑
- SpringMVC在Controller层中注入request的坑
- SpringMVC在Controller层中注入request的坑
- springMVC中controller层调用service层的方式
- 在SpringMVC的Controller中获取spring上下文和springMVC上下文
- 如何在非Controller中获取Request和Response:SpringMVC之RequestContextHolder分析
- 如何在Controller 中获取JSON文件的内容
- SpringMVC中web层controller的单元测试小demo
- 如何在线程中获取spring 管理的bean
- 如何在线程中获取spring 管理的bean
- 如何在线程中获取spring 管理的bean
- 如何在spring普通的bean中获取session对象
- spring整合SpringMVC Controller 和 Struts2 Action控制层Bean的默认作用域
- spring整合SpringMVC Controller 和 Struts2 Action控制层Bean的默认作用域
- springMVC教程(四)在controller中获取web元素
- 搞清楚 Python traceback
- base64编码学习笔记(一)
- 关于最近工作的一些想法
- 记录
- expect无信任远程批量拷贝文件
- 如何在SpringMVC 的@Controller 层中获取bean
- java注解详解
- ubuntu14.04.1 LTS 64bits较快的更新源
- JAVA注解的实际应用--生成sql语句
- TCP 偶尔出现connection refused
- js中 this 的指向
- Jvm原理剖析与调优之内存结构
- Atitit 遍历文件夹算法 autoit attilax总结
- Rust : 为什么没有lifetime是不行的?