• WebApplicationContext wac=WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());这句话的意思


    在jsp中出现

    提取的代码:

    <%
       WebApplicationContext wac = WebApplicationContextUtils
         .getWebApplicationContext(this.getServletContext());
       UserDao userDao = (UserDao) wac.getBean("userDaoImpl");
       String in=(String)request.getParameter("id");
      System.out.println(in);
       int num=Integer.parseInt(in);   
      %>
     <%=userDao.findUserById(num)%><br />

    WebApplicationContext wac=WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    WebApplicationContext 是什么?
    WebApplicationContextUtils是什么?
    this.getServletContext()又是什么?

    这句话的意思是,通过WebApplicationContextUtils工具类获取ApplicationContext对象.这个对象是通过.getServletContext()方式获取的,然后把获取的ApplicationContext对象赋值给wac。

    WebApplicationContext是spring包中的一个类
    WebApplicationContextUtils是Spring 包中的一个工具类
    getServletContext()是struts2中获取参数的方法

  • 相关阅读:
    Nginx:缓存
    Nginx:静态资源压缩
    Cassandra:安装
    Cassandra:java客户端操作
    Postgresql:Centos7安装Postgresql
    Cassandra:cql基本操作
    Cassandra:cqlsh基本命令和cql
    Cassandra:基本概念
    Nginx:rewrite功能配置
    Nginx:负载均衡
  • 原文地址:https://www.cnblogs.com/fifiyong/p/5803236.html
Copyright © 2020-2023  润新知