读书人

jsp中施用spring中的bean

发布时间: 2012-11-01 11:11:31 作者: rapoo

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>

读书人网 >JavaScript

热点推荐