JSP访问Spring中的bean

<%@page import="com.sai.comment.po.TSdComment"%>
<%@page import="com.sai.comment.service.CommentService"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="org.springframework.web.context.support.*"%>
<%@page import="org.springframework.context.*"%>
<%@page import="java.util.List"%>
<%@page import="org.springframework.web.context.support.*"%>
<%@page import="org.springframework.context.*"%>
<%@page import="com.sai.comment.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Lnua platform spy page</title>
</head>
<body><%!private CommentService commentService;@Overridepublic void init() {ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());commentService = (CommentService) ctx.getBean("commentServiceImpl");}%><%try {String commentId = request.getParameter("commentId");TSdComment comment = commentService.findById(commentId);out.println(comment.getUser().getUserName());out.println(comment.getCreateTime());out.println(comment.getCommentContext());out.println(comment.getCommentId());} catch (Exception e) {e.printStackTrace();out.print("系统繁忙");}%></body>
</html>

JSP访问Spring中的bean相关推荐

  1. Spring 中的bean 是线程安全的吗?

    点击上方蓝色"方志朋",选择"设为星标" 回复"666"获取独家整理的学习资料! 作者:myseries cnblogs.com/myser ...

  2. Spring中的Bean配置、属性配置、装配内容详细叙述

    文章目录 1.Bean的配置 1.1.配置方式 2.Bean的实例化 2.1.构造器实例化 2.2.静态工厂方式实例化 2.3.实例工厂方式实例化 3.Bean的作用域 3.1.作用域的种类 4.Be ...

  3. 第3章 Spring中的Bean详解(2)

    目录 1  Bean的装配方式 2  基于XML的装配 2.1 传入参数的类型 2.2 字面值注入(SpringDIConfig) name属性:属性的名称,与Bean中setter方法的名称一致. ...

  4. 详细讲解Spring中的@Bean注解

    点击关注公众号,实用技术文章及时了解 来源:blog.csdn.net/weixin_42140261/ article/details/104864333 随着SpringBoot的流行,我们现在更 ...

  5. java spring源码_spring源码分析-spring中的bean

    接触过spring的人都知道,在spring中我们称java对象为bean,我们在spring的debug日志或者报错日志也能看到各种bean的描述.其实,spring的bean和java的对象之间是 ...

  6. spring扩展点之二:spring中关于bean初始化、销毁等使用汇总,ApplicationContextAware将ApplicationContext注入...

    <spring扩展点之二:spring中关于bean初始化.销毁等使用汇总,ApplicationContextAware将ApplicationContext注入> <spring ...

  7. Spring中的Bean是如何被回收的?

    1.架构师系列内容:架构师学习笔记(持续更新) 答:这需要看Spring中的bean的生命周期 spring中的生命周期有比如:singleton,prototype,session,request- ...

  8. Spring中的Bean是线程安全的么?

    1.架构师系列内容:架构师学习笔记(持续更新) 答: 首先Spring 中的Bean是哪里来的? spring中的bean是初始化时,通过扫描,利用反射new出来的.并且缓存在IOC 容器中,所以Sp ...

  9. 为什么Spring中的bean默认都是单例模式?

    省流小助手:主要是为了提升性能.希望知道原理的小伙伴继续往下看. 大家都知道Spring中的bean默认情况下都是单例模式(Singleton),那为什么呢?想要弄明白这个问题,首先需要对反射有一定的 ...

最新文章

  1. Error: Default interface methods are only supported starting with Android N (--min-api 24): java.uti
  2. 单语言表征如何迁移到多语言去?
  3. 解决oracle11g的ORA-12505问题
  4. Gson解析JSON数据中动态未知字段key的方法
  5. make,makefile,cmake“暴力编译法”的个人经验或理解。
  6. TiDB集群大规模删除实践
  7. php 旋转图片 保存,如何在PHP中旋转并保存图像
  8. 手机modem开发(12)---MTK 平台如何PUSH modem 到手机中进行调试
  9. 深入理解Java:SimpleDateFormat安全的时间格式化 ;
  10. 树莓派 ubuntu gpio_树莓派学习笔记(一)输入输出GPIO
  11. 仅需10道题轻松掌握Python字符串方法 | Python技能树征题
  12. ICD-10/11 查询疾病编码方法
  13. 入侵检测工具AIDE极简教程
  14. 申请了雅虎邮箱的全新域名@yahoo.cn ID
  15. 中性市场的期权交易策略
  16. SeedLab10: Linux Firewall Exploration Lab
  17. 《Real-Time Rendering 4th Edition》全文翻译 - 第2章 图形渲染管线(上)2.1 ~ 2.3(20200720翻新)
  18. linux口令长度,Linux 的口令时效机制
  19. host ntrip 千寻rtk_「图文教程」千寻RTK连接千寻cors账号的操作步骤
  20. 2012-07-31

热门文章

  1. 转载:公司招聘中不能说的秘密
  2. 【Linux】Linux中常见的文件管理以及常用的符号命令的总结
  3. pycharm的pip配置
  4. JVM 字节码 对照表
  5. 软件测试:测试一个网站
  6. 如何使用apiPOST进行模拟发送get、post、delete、put请求(支持文件上传)
  7. JMeter基础之组件的作用域与执行顺序
  8. 性能测试之JMeter接口关联【JSON提取器】详解
  9. 传统软件测试的互联网化改造
  10. Java基础中的基础