首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jsp中施用spring中的bean

2012-11-01 
jsp中使用spring中的bean%@ page importorg.springframework.context.ApplicationContext %%@ page

jsp中使用spring中的bean
<%@ page import="org.springframework.context.ApplicationContext" %>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>

<body>
<%

ApplicationContext  ctx  =  WebApplicationContextUtils.getWebApplicationContext(getServletContext());

com.demo.service.UserService userService=(com.demo.service.UserService) ctx.getBean("userService");

System.out.println("------------->"+userService.getMessage());

%>
</body>

热点排行