问题描述:所有与struts相关的xml文件(struts_XXX.xml)报错:Referenced file contains errors (http://struts.apache.org/dtds/struts-2.0.dtd),For more infomation...
探索过程:打开http://struts.apache.org/dtds/struts-2.0.dtd链接,页面提示:
This page contains the following errors:
Below is a rendering of the page up to the first error.
发现:这个链接对应的struts-2.0.dtd文件报错,有问题。
解决:引用本地正常struts-2.0.dtd
步骤:1.打开eclipse的Window-Preferences-XML-XML Catalog(还可以在搜索框输入xml(推荐))
2.点击右侧的XML Catalog Entries旁边的“Add...”按钮
3.弹出对话框。
Location:cms-core/src/main/resources/config/struts-2.0.dtd(此为Workspace按钮从本地上传到eclipse项目中的struts-2.0.dtd文件的相对路径)
Key Type:Public ID(不需要改,默认就行)
Key:-//Apache Software Foundation//DTD Struts Configuration 2.0//EN
3.点“OK”即可添加。
注意:关于Location的填写,有两个按钮Workspace和File System。
struts-2.0.dtd文件为复制本地maven库里的D:\mavenRepository\org\apache\struts\struts2-core\2.3.32\struts2-core-2.3.32.jar文件,用360压缩解压后的文件夹中复制出来的。
其中File System为本地路径,也就是eclipse直接引用本地路径的struts-2.0.dtd的文件,你在本地运行eclipse直接引用本地的struts-2.0.dtd的文件时xml文件不会有问题,但是你把项目部署到服务器后呢?就不会引用到本地的struts-2.0.dtd文件,还是会出报错;此外,保存这个struts-2.0.dtd这个文件还需要单独存放,时间一长,某天一不小心当做垃圾删了项目就又会出问题。所以,我推荐struts-2.0.dtd要跟着项目走,及选择点击Workspace按钮,上传本地的struts-2.0.dtd到core包指定目录下。