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 是单例的.当单例中存在竞态条件,即有线程安全问题.如下面的例子 计 ...
随机推荐
- Android之聊天室设计与开发
我们要设计和实现一个有聊天室功能的APP,需要服务器不断读取来自客户端的信息,并即时地将信息发送给每个连接到本服务器上的客户端,每个客户端可以向服务器发送消息,并不断地接收来自服务器的消息,并将消息显 ...
- MVC4 使用 ckfinder+ckeditor编辑器
配置ckfinder for asp.net 版本下载地址 http://cksource.com/ckfinder/downloadckeditor下载地址 http://ckeditor.com ...
- Game start
今天开始有计划的码代码吧!!我可是以后要进微软或者google的男人.初步计划先学习编程之美吧,每天码一到题的解法,每天每天每天..然后是ACM竞赛基础,每天一节同上.最后..不对,冷静冷静,我已经没 ...
- jsp中页面间传汉字参数转码
转码:a.href="./showCont.jsp?tcontent="+encodeURI(encodeURI(tcontent)); 解码:java.net.URLDecode ...
- Today’s dictation
A united nations expert on human rights in north korea has warned that the country's dictator, kim j ...
- 20141030--SQL2008常用命令-1
create database biao2--创建新的数据库 go use biao2 go create table shuiguo--创建表shuiguo ,create table创建表 ( 序 ...
- Mongo客户端MongoVUE的基本使用
这里没有涉及到服务器以及客户端的安装,文章主要介绍mongo客户端mongoVUE的使用 一.数据库连接 点击绿色加号添加一个连接,输入name.server.port,点击save,点击connec ...
- C# 中有关 using 关键字
关于 C# 中的 using 关键字 我们往往只在代码的开头使用 using 关键字来引入名称空间,这是 using 的一个最常见的使用. 但是,using 关键字是否只有这么一处用武之地吗? 下面, ...
- ZigBee安全相关
ZigBee安全由AES加密算法和CCM操作方式作为安全方案,广泛使用在ZigBee联盟的通信协议中.ZDO层负责安全策略和安全配置的管理. Technorati 标签: ZigBee 安全 2. 配 ...
- 关于java的转义字符
关于java的转义字符 我们都知道 String s="ad,dfjdlfs,df,s,dfl"; 执行 String re[]=s.split(&qu ...