1

Struts2 を発見したばかりで、web.xmlファイルに問題があります。

フィルタータグの近くでエラーが発生します:

<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>`
4

1 に答える 1

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ました。代わりに使用してください。

于 2012-12-07T16:39:14.070 に答える