2013-03-13 5 views
6

私はこのエラーがのEclipse(junoバージョン)Markersビューにあるこのweb.xmlコードに何が起こっているのか不思議です。ここで なぜweb.xml 'context-param'に文字[children]を使用できないのですか?

はコードです:あなたはXMLノードのparam-値

あなたが使用することを許可されていない「/」、「<」や他の文字内の不正な文字を使用している初心者のために

<?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> 
+0

? –

+0

奇妙なサーブレットSpecefication 2.5では、param-nameとparam-valueを使用できます。たぶんそれはEclipseの問題だ –

+0

私はこれの根本的な原因はわからなかった、私はちょうどプロジェクトを放棄し、再び再作成します。 – huahsin68

答えて

9

ノード内ではXML文書の解析を中断するためです。

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

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

これは問題を引き起こしていました。

+3

'/'はXMLノード内の有効な文字です。 – Tamas

+2

"/"が誤解を招いていても(明らかに十分)、良い回答です。私の問題は、パラメータ値に@文字がありました。 – MrLymy

+0

ポインタありがとうございます。私の場合は、リクエストに迷いがあるためです。私はこのエラーは具体的ではないと思います。間違ったことが原因で発生する可能性があります。 –

2

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

xmllint --noout --schema http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd XML_FILE 
あなたは終了タグをコメントしている
0

<filter-mapping>で再び見て:DTDは、その要素が子を持つことができないため

<filter-mapping> 
<filter-name>springSecurityFilterChain</filter-name> 
<url-pattern>  /*</url-pattern> 
</filter-mapping>` 
関連する問題