ApplicationContext是Spring的容器環境
在Web開發開發中
一
<?xml version=
<web
xmlns:xsi=
xsi:schemaLocation=
version=
<context
<param
<param
</context
<filter>
<filter
<filter
</filter>
<filter
<filter
<url
</filter
<listener>
<listener
</listener>
<servlet>
<servlet
<servlet
<load
</servlet>
<servlet
<servlet
<url
</servlet
</web
<%@ page import=
<%@ page import=
<%@ page import=
<%@ page contentType=
<html>
<head><title>Simple jsp page</title></head>
<body>
<%
// ApplicationContext ctx = WebApplicationContextUtils
ApplicationContext ctx = WebApplicationContextUtils
TestService service = (TestService) ctx
String s = service
out
%>
</body>
</html>
二
在此環境下web
<?xml version=
<web
xmlns:xsi=
xsi:schemaLocation=
version=
<context
<param
<param
</context
<listener>
<listener
</listener>
<servlet>
<servlet
<servlet
<load
</servlet>
<servlet
<servlet
<url
</servlet
</web
獲取的方式和上述完全一樣
下面給出本例子的工程源碼
下載附件
testspringweb
testspringweb
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28929.html