zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    mysql六:数据备份、pymysql模块
    mysql三:表操作
    mysql四:数据操作
    剑指offer-数组
    剑指offer-回溯
    中缀表达式到后缀表达式的转换
    大数取余算法的证明及实现
    Windows下匿名管道进程通信
    Windows下使用命令行界面调用VS2015编译器编译C++程序方法
    6 个技巧,提升 C++11 的 vector 性能
  • 原文地址:https://www.cnblogs.com/mjorcen/p/4056904.html
Copyright © 2011-2022 走看看