问题是:Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: ServletContext resource [/WEB-INF/context/applicationContext.xml]这是spring的application。xml:<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:flex="http://www.springframework.org/schema/flex"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/flex 
           http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd">
  
    <context:property-placeholder location="classpath:../properties/loginTest.properties" />
    <bean id="userLogin_user"
        class="org.apache.commons.dbcp.BasicDataSource" 
        destroy-method="close">
        <property name="driverClassName"
                  value="com.mysql.jdbc.Driver" />        
        <property name="url"
                  value="${db-user.url}" />
        <property name="initialSize" value="${db-user.initial-pool-size}"></property>
        <property name="username" value="${db-user.username}" />
        <property name="password" value="${db-user.password}" />
        <property name="poolPreparedStatements" value="true" />
        <property name="validationQuery" value="select 1" />
        <property name="maxWait" value="10000"/>
        <property name="maxActive" value="50" />
        <property name="maxIdle" value="-1" />
    </bean>
    <bean id="userdao" class="UserDao" factory-method="getInstance" >
        <property name="dataSourceUser" ref="userLogin_user" />
    </bean>
    </beans>web.xml是:          <?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
    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">
    <!--连接池配置 begins -->
    <resource-ref> 
    <description>DB Connection</description> 
    <res-ref-name>jdbc/userinfo</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
  </resource-ref> 
    
    <!--连接池配置 end  -->
    
  <!-- spring begin-->
  <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/context/*.xml;</param-value>
    </context-param>
    <servlet>
        <servlet-name>SpringContextServlet</servlet-name>
        <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
<!-- spring end -->
  <servlet>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>LoginServlet</servlet-class>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/loginServlet</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
帮帮忙谢谢!

解决方案 »

  1.   

    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:flex="http://www.springframework.org/schema/flex"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
      http://www.springframework.org/schema/flex 
      http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-2.5.xsd">把关于namespace的去掉或者把上面那些换成<beans>试试。