`
ldzyz007
  • 浏览: 724663 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

Document root element "beans", must match DOCTYPE

阅读更多
struts2+spring2+hhibernate3开发时在项目中引入了一个XFire开发的web service客户端后
报错:org.xml.sax.SAXParseException:Document root element "beans", must match DOCTYPE
原因:spring配置文件中没有声明:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

如果bean要声明scope或者singleton
在spring2.0之前bean只有2种作用域即:singleton(单例)、non-singleton(也称prototype), Spring2.0以后,增加了session、request、global session三种专用于Web应用程序上下文的Bean。

<!-- using spring-beans-2.0.dtd -->
<bean id="accountService" scope="prototype"/>
<!-- the following is equivalent and preserved for backward compatibility in spring-beans.dtd -->
<bean id="accountService" singleton="false"/>

如果你用"singleton"属性那么就必须在那个文件里  引用'spring-beans.dtd' DTD。 如果你用"scope"属性那么必须 在那个文件里引用'spring-beans-2.0.dtd' DTD 或'spring-beans-2.0.xsd' XSD
分享到:
评论
1 楼 pdw2009 2012-08-15  
呵呵,说得极对!

相关推荐

Global site tag (gtag.js) - Google Analytics