在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中获取参数的方法

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2022-03-04
  • 2021-11-06
  • 2021-07-27
猜你喜欢
  • 2021-10-12
  • 2021-04-10
  • 2022-01-16
  • 2021-04-12
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
相关资源
相似解决方案