JSP访问Spring中的bean
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; @Override
public 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的更多相关文章
- Thymeleaf:访问Spring中的bean
项目做了动静分离,即静态文件全部放在nginx中,动态文件在tomcat中,如何引用静态文件,我是这么做的,见下: 运行结果:
- Spring 中的bean 是线程安全的吗?
结论: 不是线程安全的 Spring容器中的Bean是否线程安全,容器本身并没有提供Bean的线程安全策略,因此可以说Spring容器中的Bean本身不具备线程安全的特性,但是具体还是要结合具体sco ...
- 【Spring】Spring中的Bean - 5、Bean的装配方式(XML、注解(Annotation)、自动装配)
Bean的装配方式 简单记录-Java EE企业级应用开发教程(Spring+Spring MVC+MyBatis)-Spring中的Bean 文章目录 Bean的装配方式 基于XML的装配 基于注解 ...
- Spring 中的 bean线程安全性分析
首先:Spring 中的 bean不是线程安全的 Spring容器中的Bean是否线程安全,容器本身并没有提供Bean的线程安全策略,因此可以说Spring容器中的Bean本身不具备线程安全的特性,但 ...
- 传统javabean与spring中的bean的区别
javabean已经没人用了 springbean可以说是javabean的发展, 但已经完全不是一回事儿了 用处不同:传统javabean更多地作为值传递参数,而spring中的bean用处几乎无处 ...
- 1.2(Spring学习笔记)Spring中的Bean
一.<Bean>的属性及子元素 在1.1中我们对<Bean>有了初步的认识,了解了一些基本用法. 现在我们进一步理解<Bean>属性及子元素. 我们先来看下< ...
- spring扩展点之二:spring中关于bean初始化、销毁等使用汇总,ApplicationContextAware将ApplicationContext注入
<spring扩展点之二:spring中关于bean初始化.销毁等使用汇总,ApplicationContextAware将ApplicationContext注入> <spring ...
- 第2章 Spring中的Bean
2.1 Bean的配置 Bean本质是Java中的类.Spring可以被看做一个大型工厂,这个工厂的作用就是生产和管理Spring容器zho中的Bean.想在项目中使用这个工厂,就需要对Spring的 ...
- spring 中的 bean 是线程安全的吗?
spring 中的 bean 是线程安全的吗? Spring 不保证 bean 的线程安全. 默认 spring 容器中的 bean 是单例的.当单例中存在竞态条件,即有线程安全问题.如下面的例子 计 ...
随机推荐
- x64、x86_64、x64三者的区别
x86是指intel的开发的一种32位指令集,从386开始时代开始的,一直沿用至今,是一种cisc指令集,所有intel早期的cpu,amd早期的cpu都支持这种指令集,ntel官方文档里面称为“IA ...
- Windows删除大文件
Temp是目录 或者是 文件很大很大很大很大 cmd rd /s /q Temp
- Objective-C 【从文件中读写字符串(直接读写/通过NSURL读写)】
———————————————————————————————————————————从文件中读写字符串(直接读写/通过NSURL读写) #import <Foundation/Foundati ...
- 8个3D视觉效果的HTML5动画欣赏
现在的网页中应用了越来越多的3D应用,特别是基于HTML5 Canvas的动画特效,让用户有一种非常震撼的视觉体验.本文收集了8个非常炫酷的3D视觉效果的HTML5动画,都有源代码分享,你可以学习你感 ...
- JAVA设计模式(DESIGN PATTERNS IN JAVA)读书摘要 第1部分接口型模式——第4章 外观(Facade)模式
外观模式就类似于一个工具包,一个类对应一个功能. 外观模式的意图是为子系统提供一个接口,便于它的使用. 书中给出的例子是画一个哑弹的飞行路径, 初始的类的设计是这样的,看下图, ShowFlight类 ...
- windows phone 手机截图
无聊在商城找了一款小游戏玩,看到一个截屏功能,就google了一下具体实现,还是比较简单的,主要是靠WriteableBitmap(提供一个可写入并可更新的 BitmapSource)类实现.看一下m ...
- gprof
函数级耗时剖析.gprof不会说谎,仔细考虑下函数的实现细节. 准备工作 对单文件simulator.cpp编译 编译:g++ -g -pg simulator.cpp -o simulator.o ...
- Eclispe使用Maven添加官方库的jar包
先到百度或google搜索maven仓库,在仓库中搜索需要的jar包,如poi.jar. 搜索到之后找到需要的jar包,找到这里
- shell编程基础练习
shell作为一个人机交互的接口,在Linux中发挥着很大的作用,而shell编程则是减轻系统工程师工作的利器,这里总结一下shell编程的主要内容(趁着程序运行的空档). 本文的基本结构是shell ...
- JQGrid+Webservice+LINQ
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="jqgridtest.asp ...