首先在jsp中导入:
然后可以调用Spring容器管理的Bean了:
<jsp:directive.page import="org.springframework.web.context.WebApplicationContext"/>然后可以调用Spring容器管理的Bean了:
<%
WebApplicationContext context = (WebApplicationContext)this.getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
TestService service = (TestService)context.getBean("bean ID");
%>
本文详细介绍了如何在JSP中导入Spring框架,并通过WebApplicationContext调用其管理的Bean,包括导入语句、获取上下文实例及使用Bean的方法。
1027

被折叠的 条评论
为什么被折叠?



