<%@ 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>
<%@ 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>
Spring框架与UserService交互示例
本文展示了如何在Spring框架中获取并使用已注入的服务组件,以实现特定业务功能的调用。
403

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



