Myeclipse 中struts.xml突然报错

代码运行的好好的突然就报错了,错误提示如下:

Referenced file contains errors (http://struts.apache.org/dtds/struts-2.0.dtd). For more information, right click on the message in the Problems View and select
"Show Details..."

这样的错其实遇见过几次了,但每次再遇到的时候有不知所措了,所以记下来以便自己以后查找。

在Problems窗口中找到该消息,详情显示

The errors below were detected when validating the file "struts-2.0.dtd" via the file "struts.xml". In most cases these errors can be detected by validating "struts-2.0.dtd" directly. However it is possible that errors will only occur when struts-2.0.dtd is validated in the context of struts.xml.


原因找到了,找不到指定的dtd文件!jar包是肯定没错的,毕竟之前是能运行的,那么有错的就只能是 “http://struts.apache.org/dtds/struts-2.0.dtd” 这一句了。开始我怀疑是不是struts2不行了,后来到网上一查,结果是之前启动Myeclipse的时候没有网。

好吧,上解决办法。

1、现在有网了,为什么还显示有错误,Myeclipse缓存的问题。对struts.xml进行粘贴复制操作:ctrl +all--->ctrl+x---->ctrl+s--->ctrl+v

当然也有可能不成功,为什么,不知道。我的解决办法是重启Myeclipse然后再执行上面的操作,成功。

2、你有可能正处在一个没网的环境下,但是恰好你有那么一点点强迫症,下面这个方法就正适合你。

在顶上的myeclipse中单击preference--->myeclipse--->Files and Editors--->XML--->XML Catalog,选中右上方的User Specified Entries,单击add按钮,找到该dtd文件在本地的

路径:struts-2.1.8\src\core\src\main\resources\struts-2.0.dtd,Key Type 中选择uri,key中输入以下路径:http://struts.apache.org/dtds/struts-2.0.dtd,点击确定。回到struts.xml后

在任意位置输入空格保存就行了!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值