简体   繁体   中英

eclipse not validating the struts.xml file

I installed the eclipse in my new pc and import my old project of struts2 in that and after importing the project i got a warning in struts.xml file ie "The file cannot be validated as there was a connection problem.". I replaced my jar files and doctype so many times but still it didn't work. I also found that eclipse is not showing me any error if i do something wrong in that file even when eclipse clean my project it takes a lot of time to clean struts.xml file

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
 <package name="a" extends="struts-default">
 <action name="b" class="com.test">
   <result name="success">/success.jsp</result>
         <result name="error">/error.jsp</result>
      </action>

 </package>

</struts>

Please help me for this i am getting lots of difficulties...???

Change Doctype to:

 <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
    "/WEB-INF/dtds/struts-2.1.dtd">

and extract "struts-2.1.dtd" file from "struts2-core-2.1.8.1.jar" into dtds folder(CREATE NEW) inside WEB-INF folder.

This happens when eclipse could not open the file, this happens sometimes for me when I have internet connection problems.

So make sure you have internet connection and you have not set any proxy which is not working and prevent eclipse to access the internet. You can open struts.xml and ctl+click on http://struts.apache.org/dtds/struts-2.3.dtd

If your problem is not solved, you can do as mentioned by @AsSide, copy the struts-2.3.dtd some where in your hard and change the struts.xml as below:

<!DOCTYPE struts SYSTEM "c://struts-2.3.dtd">

The DOCTYPE must be changed to SYSTEM instead of PUBLIC . Change the dtd location is not a good approach :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM