7

Eclipse (juno バージョン)ビューでweb.xmlこのエラーが発生した場合、このコードに何が起こるのか興味があります。cvc-complex-type.2.3: Element 'context-param' cannot have character [children], because the type's content type is element-only.Markers

コードは次のとおりです。

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 
        version="2.5" 
        xmlns="http://java.sun.com/xml/ns/javaee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

  <display-name>Spring security web application (series)</display-name>

  <!-- to specifically stop trouble with multiple apps on tomcat -->
  <context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>customauth_root</param-value>
  </context-param>

  <!-- Location of the XML file that defines the root application context
    applied by ContextLoaderListener. -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        WEB-INF/applicationContext.xml
        WEB-INF/applicationContext-security.xml
        </param-value>
  </context-param>

  <!-- Loads the root application context of this web app at startup. The
    application context is then available via WebApplicationContextUtils.getWebApplicationContext(servletContext). -->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <listener>
    <listener-class>
      org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
  </listener>

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

  <!-- Provides core MVC application controller. See customauth-servlet.xml. -->
  <servlet>
    <servlet-name>customauth</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>customauth</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>customauth</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

</web-app>
4

4 に答える 4

9

まず、XML ノードの param-value 内で不正な文字を使用しています

XML ドキュメントの解析が中断されるため、ノード内で「/」、「<」、およびその他の文字を使用することはできません。

XML ノード内の値の周りに CDATA または PCDATA ラッパーを使用する必要があります。

例えば

    <param-value><![CDATA[
        WEB-INF/applicationContext.xml
        WEB-INF/applicationContext-security.xml]]>
    </param-value>

これが問題の原因でした。

于 2013-04-10T13:38:09.027 に答える
2

一部の非表示文字は XML 空白と見なされないため、エラーが表示されます。Eclipse の「テキスト エディター」設定を構成してすべての空白文字を表示すると、ルージュ文字が目立ちます。このツールを使用して、XML ファイルを検証することもできます。

xmllint --noout --schema http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd XML_FILE
于 2013-10-07T16:29:03.183 に答える
0

終了タグにコメントしています。もう一度見てください<filter-mapping>:

 <filter-mapping>
 <filter-name>springSecurityFilterChain</filter-name>
 <url-pattern>      /*</url-pattern> 
 </filter-mapping>`
于 2016-05-23T17:02:28.390 に答える
0

このエラーは、xmlにタイプミスがあることを意味します。XML をフォーマットしてみると、タイプミスが目立ちます。

于 2019-03-18T20:06:01.403 に答える