创建四个文件
web.xml  Person applicationContext.xml  test.jsp
----------------------------------------------------
web.xml
<?xml version="1.0" encoding="GBK"?><web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"><filter>
<filter-name>requestContextFilter</filter-name >
<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>requestContextFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping></web-app>
--------------------------------------------
Person.java
public class Person
{
private int age;

}
---------------------------------------------
applicationContext.xml  
<?xml version="1.0" encoding="GBK"?>
<!-- 指定Spring配置文件的DTD信息 -->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!-- Spring配置文件的根元素 -->
<beans>
<!-- 指定使用request作用域 -->
<bean id="p" class="lee.Person" scope="request"/>
</beans>
-----------------------------------------------
test.jsp
  <body>
    <%
WebApplicationContext ctx = 
WebApplicationContextUtils.getWebApplicationContext(application);
Person p1 = (Person)ctx.getBean("p");
Person p2 = (Person)ctx.getBean("p");
System.out.println(p1 == p2);
System.out.println(p1);
%>
  </body>
-------------------------------------
错误
root cause java.lang.NullPointerException
org.apache.jsp.test_jsp._jspService(test_jsp.java:91)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)