1.定义jsp_top.jsp
<%
ServletConfig config1 = getServletConfig();
ServletContext context = config1.getServletContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
%>
2.在使用的jsp页面中使用包含:
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ page
import="java.util.*,org.springframework.context.ApplicationContext"%>
<%@ page
import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="com.hdsm.xxcj.person.*;"%>
<%@ include file="../../public/jsp_top.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String str = request.getParameter("id").toString();
System.out.print(str);
XxcjPersonMain main = (XxcjPersonMain) ctx
.getBean("XxcjPersonMain");
Iterator it = main.getPersonInfoByD401(str.split(";")[0], str
.split(";")[1], request);
Iterator it2 = main.loadPersonInfo(str.split(";")[0], str
.split(";")[1], request);
%>
注意:在调用指定的类事,该类已经在applicationContext.xml中进行了配置; 这样就方便多了!