首页 > 代码库 > JSP访问Spring中的bean
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。