目录
The prefix "util" for element "util:list" is not bound"
The prefix "aop" for element "aop:config" is not bound.
spring 配置问题:
Spring配置文件标签报错:The prefix "XXX" for element "XXX:XXX" is not bound.
The prefix "util" for element "util:list" is not bound"
解决方法:
在spring的头部文件中没有引入:
xmlns:util="http://www.springframework.org/schema/util"
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
要用到Spring的util(包括util:list等),xml文件中的beans中需要添加一些有关util的信息:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> <!-- bean definitions here -->
</beans>
首先定义一个City类,City.java
package com.habuma.spel.cities;
public class City {
private String name;
private String state;
private int population;
public City(){};
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getState(){
return state;
}
public void setState(String state){
this.state = state;
}
public int getPopulation(){
return population;
}
public void setPopulation(int population){
this.population = population;
}
}
使用<util:list>元素在Spring里spring-idol.xml配置一个包含City对象的List集合
<!-- 2.3.3 在SpEL中筛选集合 -->
<util:list id="cities">
<bean class="com.habuma.spel.cities.City"
p:name="Chicago" p:state="IL" p:population="2853114"/>
<bean class="com.habuma.spel.cities.City"
p:name="Atlanta" p:state="GA" p:population="537958"/>
<bean class="com.habuma.spel.cities.City"
p:name="Dallas" p:state="TX" p:population="1279910"/>
<bean class="com.habuma.spel.cities.City"
p:name="Houston" p:state="TX" p:population="2242193"/>
<bean class="com.habuma.spel.cities.City"
p:name="Odessa" p:state="TX" p:population="90943"/>
<bean class="com.habuma.spel.cities.City"
p:name="El Paso" p:state="TX" p:population="613190"/>
<bean class="com.habuma.spel.cities.City"
p:name="Jal" p:state="NM" p:population="1996"/>
<bean class="com.habuma.spel.cities.City"
p:name="Las Cruces" p:state="NM" p:population="91865"/>
</util:list>
<util:list>元素是由Spring的util命名空间所定义的。它创建了一个java.util.List类型的Bean,这个集合里包含了所有以上配置的Bean。
The prefix "aop" for element "aop:config" is not bound.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
</bean>