解决Struts2配置文件无提示问题

来源:互联网 发布:编程猫李天驰个人简介 编辑:程序博客网 时间:2024/05/21 09:18

 

问题:有时在开发第一个Web项目时,在配置文件中打个”<”后,并没有任何的提示信息(快捷键Alt+/也不提示)

 

原因:找不到配置文件头中声明的dtd文件

 

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

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

<struts>

    <package name="package-one" extends="struts-default" namespace="/">

    </package>

</struts> 

 

解决方法:

1) 联网,联网后,IDE会自动下载声明的dtd文件

2) 自己动手配置dtd文件,步骤如下:

   1,找到Struts2发行包中的 struts-2.1.dtd文件


   2,打开MyEclipseWindow--Preferences--MyEclipse—-

Files and Editors—XML—XML Catalog


   3,单击右侧的 Add 按钮,添加一个 Add XML Catalog Entry,里面的有三个参数分别是:

     Location File System找到刚刚找到的struts-2.1.dtd文件。

     Key Type : 选 URI

     Key http://struts.apache.org/dtds/struts-2.1.dtd

Key的取值根据struts-2.1.dtd文件中红色字体部分而来。

<!--

   Struts configuration DTD.

   Use the following DOCTYPE

 

   <!DOCTYPE struts PUBLIC

    "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"

    "http://struts.apache.org/dtds/struts-2.1.dtd">

-->

 

 

然后 OK,提示就可以显示了。

原创粉丝点击