将eclipse中的struts1项目的导入到myeclipse2014后发现struts-config.xml不能用默认的编辑器打开,报错如下:
Project Struts1Test is not configured as a MyEclipse Web-Struts Project. Therefore the MyEclipse Struts Editor may not be used with struts-config.xml. The default XML Editor has been used to open the file instead.
解决方法如下:
方法1. 临时解决,在struts-config.xml上右键----->选择openwith----->选择 myeclipse XML Editor。这样就没法使用图形化的界面了。
方法2.项目上右键,选择MyEclipse--->选择Project Facets [Capabilities] ----->选择Install Apache Struts(1.x) Facet
弹出窗口选择对应的struts版本和服务器,我这选择的1.2,如果没有服务器环境可以新建一个。
这个时候会提示:" Servlet named action already exists." ,这个地方是说明你的web.xml中已经有了对应的action配置了
接下来是最关键的地方了,先将web.xml改名为web.xml.bak,再重复上面Install Apache Struts(1.x) Facet的步骤,你会发现这次没有提示错误,直接点击finish就可以,期间可能会提示tld文件已经存在,请点击no to all即可。
系统会自动生成新的web.xml,此时删除新的web.xml,用web.xml.bak改回web.xml,然后在myeclipse的struts-config.xml上右键选择openwith ,选择myeclipse struts config editor就可以了。如果有错误提示,关了这个文件重新打开即可。
至此就可以正常用编辑器打开了文件了。