2017-05-10 10 views
0

現在のweb.xmlファイルは次のようになります。これは何のエラーも表示されません。web.xmlの内容を整理する必要がありますか?

<!DOCTYPE web-app PUBLIC 
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd" > 

<web-app> 
<display-name>Archetype Created Web Application</display-name> 

<context-param> 
<param-name>contextConfigLocation</param-name> 
<param-value>classpath:com/udemy/spring/config/security-context.xml</param-value> 
</context-param> 

<filter> 
<filter-name>springSecurityFilterChain</filter-name> 
<filter- 
class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
</filter> 

<filter-mapping> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

<listener> 
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

<servlet> 
    <servlet-name>dispatcherServlet</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
<load-on-startup>1</load-on-startup> 
</servlet> 
<servlet-mapping> 
<servlet-name>dispatcherServlet</servlet-name> 
<url-pattern>/</url-pattern> 
</servlet-mapping> 
</web-app> 

しかし、たとえば私がコードオーダーを再整理すると、この

<filter> 
<filter-name>springSecurityFilterChain</filter-name> 
<filter- 
class>org.springframework.web.filter.DelegatingFilterProxy</filter- 
class> 
</filter> 

<filter-mapping> 
<filter-name>springSecurityFilterChain</filter-name> 
<url-pattern>/*</url-pattern> 
</filter-mapping> 

<context-param> 
<param-name>contextConfigLocation</param-name> 
<param-value>classpath:com/udemy/spring/config/security-context.xml</param-value> 
</context-param> 

のように私はこのエラーを取得しています: -

The content of element type "web-app" must match "(icon?,display- name?, 
description?,distributable?,context-param*,servlet*,servlet- 
mapping*,session-config?,mime- mapping*,welcome-file-list?,error- 
page*,taglib*,resource-ref*,security-constraint*,login- 
config?,security- role*,env-entry*,ejb-ref*)". 

誰かがその理由であるかもしれないものを私に説明できますか?

+0

ウェブアプリですタグを2番目の例で使用しますか?そしてどのラインであなたはこれらのエラーを得る? – Jens

答えて

0

web.xmlファイルは、dtdまたはxmlスキーマで検証されます。 web.xml要素の順序は、あなたが最初の行に指定されているDTDファイルで定義されている

0

このDTDに従ってhttp://java.sun.com/dtd/web-app_2_3.dtd

タグのだから、web.xmlのは、厳密に定義された順序によって、この例では

あなたはこのファイルを開く場合は、次のよう web.xml

http://java.sun.com/dtd/web-app_2_3.dtd

を検証するために使用されるようにすることは、あなたは順序が表示されます。

  1. アイコン
  2. 表示名
  3. 説明
  4. ...など、それがこの要素で定義されたよう

<!ELEMENT web-app (icon?, display-name?, description?, distributable?, 
context-param*, filter*, filter-mapping*, listener*, servlet*, 
servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?, 
error-page*, taglib*, resource-env-ref*, resource-ref*, security- constraint*, 
login-config?, security-role*, env-entry*, ejb-ref*, ejb-local-ref*)> 
関連する問題