2012-05-08 51 views
4

我想運行一個彈簧應用程序。我的web.xml看起來java.lang.IllegalStateException:在啓動彈簧應用程序時沒有名爲encodingFilter的過濾器

<?xml version="1.0" encoding="utf-8"?> 
&lt;web-app 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> 


<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>WEB-INF/beans.xml</param-value> 
</context-param> 

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

<servlet> 
    <servlet-name>CXFServlet</servlet-name> 
    <servlet-class> 
     org.apache.cxf.transport.servlet.CXFServlet 
    </servlet-class> 
    <load-on-startup>1</load-on-startup> 
</servlet> 

<servlet-mapping> 
    <servlet-name>CXFServlet</servlet-name> 
    <url-pattern>/version/2.0/*</url-pattern> 
</servlet-mapping> 
<filter-mapping> 
    <filter-name>encodingFilter</filter-name> 
    <url-pattern>/version/2.0/*</url-pattern> 
</filter-mapping> 
<filter> 
     <filter-name>encodingFilter</filter-name> 
     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 
     <init-param> 
      <param-name>encoding</param-name> 
      <param-value>utf-8</param-value> 
     </init-param> 
     <init-param> 
      <param-name>forceEncoding</param-name> 
      <param-value>true</param-value> 
     </init-param> 
    </filter> 

,我得到錯誤

java.lang.IllegalStateException:在org.eclipse.jetty.servlet.ServletHandler.updateMappings無過濾器命名爲encodingFilter (ServletHandler的.java:1148) 在org.eclipse.jetty.servlet.ServletHandler.setFilterMappings(ServletHandler.java:1249) 在org.eclipse.jetty.servlet.ServletHandler.addFilterMapping(ServletHandler.java:1079)

和我創建一個碼頭,PKG爲jar文件並運行它作爲 的Java

+0

我剛跑了你的代碼在碼頭7個作品的魅力 – ant

回答

3

我讀的地方,<過濾>前應<過濾器映射>創建。我換位置,並能修復它..

0

您正在使用什麼版本的碼頭-jar myjar.jar?

它可能與此錯誤有關嗎?

http://jira.codehaus.org/browse/JETTY-1113

+0

我使用碼頭6,它有修復它.. – harshit

+0

其中6?只有在6.1.21之後,它才被修復...... –

0

web.xml XSD定義,只要更新到新版本像3.1

<?xml version="1.0" encoding="utf-8"?> 
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> 
相關問題