您的位置:首页 > 其它

Document root element "beans", must match DOCTYPE root "null".的错误提示

2009-11-15 17:14 405 查看
Document root element "beans", must match DOCTYPE root "null".的错误提示

配置文件spring.xml有两种格式,注意和你引用的版本相匹配就不会出错了:

1.x use XML DTD方式

2.x use schema方式(因为向后兼容,所以也可以使用XML DTD方式)

spring 2.x use schema设置方式

XML Schema的设置方式
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean>
...

</bean>
</beans>

sprign 1.x 使用DOCTYPE设置方式

XML DTD的设置方式,如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="helloBean"
class="onlyfun.caterpillar.HelloBean">
<property name="helloWord">
<value>Hello!Justin!</value>
</property>
</bean>
</beans>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐