2012-12-07 40 views
1

我只是發現Struts2,並且我在web.xml文件中遇到問題。Struts2:在根目錄下的文檔中的標記必須是格式良好的

它給我的過濾器標籤附近的錯誤:

<filter> 
    <filter-name>struts2</filter-name> 
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 
</filter> 

錯誤說:這條線找到多個註釋: - 開始元素<filter> 的標籤 - 文檔中的標記的根元素以下必須很好 - 組成。

什麼問題?我該如何解決它?

謝謝!

感謝亞歷山大對你的興趣:

這裏是我的web.xml文件:

`<?xml version="1.0" encoding="UTF-8"?> 
<web-app> 
    <display-name>struts2example</display-name> 
    <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 
</web-app> 

<filter> 
    <filter-name>struts2</filter-name> 
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 
</filter> 
<filter-mapping> 
    <filter-name>struts2</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping>` 
+0

顯示整個'web.xml'文件。 –

+0

感謝Aleksandr M有我的整個'web.xml'文件 – user1885868

回答

2

你把標籤<web-app>根標籤之外。把你的<filter><web-app>

<?xml version="1.0" encoding="UTF-8"?> 
<web-app> 
    <display-name>struts2example</display-name> 
    <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 

    <filter> 
    <filter-name>struts2</filter-name> 
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 
    </filter> 
    <filter-mapping> 
    <filter-name>struts2</filter-name> 
    <url-pattern>/*</url-pattern> 
    </filter-mapping> 
</web-app> 

而且org.apache.struts2.dispatcher.FilterDispatcher是從Struts 2.1.3棄用,請org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter代替。

+0

它工作!非常感謝Aleksandr! – user1885868

相關問題