我使用Maven 3.3和JBoss 7.1.3.Final(Java 6)。我想在我的Web應用程序中包含一個過濾器,以便所有傳入的請求數據都將被編碼爲UTF-8。所以我說這我的web.xml文件如何在我的Maven項目中正確包含「org.apache.catalina.filters.SetCharacterEncodingFilter」過濾器?
<filter>
<filter-name>CharsetFilter</filter-name>
<filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>requestEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharsetFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
這Maven的依賴......
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.0</version>
</dependency>
但在部署我的應用程序,我得到下面的錯誤...
WFLYCTL0186: Services which failed to start: service jboss.undertow.deployment.default-server.default-host./myproject.UndertowDeploymentInfoService: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./myproject.UndertowDeploymentInfoService: java.lang.ClassNotFoundException: org.apache.catalina.filters.SetCharacterEncodingFilter from [Module "deployment.myproject.war:main" from Service Module Loader]
依賴什麼是否需要包含以便我的應用程序能夠成功部署?
您聲稱您使用的是JBoss 7.1.3,但是您的錯誤消息來自直到WildFly 8.x纔出現的錯誤消息。 @BalusC:我認爲所有JBossAS版本(不包括基於WildFly的JBoss EAP)都使用Tomcat作爲其Web容器的基礎;他們在將名稱更改爲WildFly的時候開始轉向 –