2016-12-30 13 views
8

私はJava 6、JBoss 7.1.3およびSpring 3.2.11.RELEASEを使用しています。私たちは、JSPページの最上部に各JSPファイルに触れることなく、すべてのJSPに対してpageEncodingを設定するにはどうすればよいですか?

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 

を指定しない限り、我々はアプリケーションコンテキスト私は私のJSPに気づく

<bean id="systemPrereqs" 
    class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> 
    <property name="targetObject" value="#{@systemProperties}" /> 
    <property name="targetMethod" value="putAll" /> 
    <property name="arguments"> 
     <!-- The new Properties --> 
     <util:properties> 
      <prop key="org.apache.catalina.connector.URI_ENCODING">UTF-8</prop> 
     </util:properties> 
    </property> 
</bean> 

でこれを設定しているという事実にもかかわらず、特殊文字が正しく表示されません。これは1つのJSPにとっては問題ありませんが、アプリケーション全体でこれらのディレクティブを追加する必要があるのは面倒です。 Springのコンテキストやどこかのように、これを指定できるよりグローバルな場所はありますか?上記のディレクティブをすべてのJSPページに普遍的に追加しますか?

答えて

0

また、次のシステムプロパティを追加します。

<jsp-config> 
    <jsp-property-group> 
    <url-pattern>*.jsp</url-pattern> 
    <page-encoding>UTF-8</page-encoding> 
    <default-content-type>text/html</default-content-type> 
    </jsp-property-group> 
</jsp-config> 

詳細情報:あなたのweb.xmlに以下の入れ

<property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/> 
+0

これは動作しませんでしたが、動作しませんでした。 – Dave

0

は、あなたのweb.xmlに以下を入れて。

<jsp-config> 
    <jsp-property-group> 
     <url-pattern>*.jsp</url-pattern> 
     <page-encoding>UTF-8</page-encoding> 
    </jsp-property-group> 
</jsp-config> 
+0

こんにちは、あなたの答えは1/6に入力されたcode_angelとどう違うのですか? – Dave

+0

私は別の行 'default-content-type'を追加してもう一度それを作り直しました;) –

+0

K、元の答えが私のためにはうまくいかなかったので、私はその指示を出してください。 dbと 'Evidence' '(賢明な引用符に気付くと、それらをカットアンドペーストしてもらうことを望んでいる)がまだ「と証拠? ' – Dave

0

フィルタの使用はどうですか?

<filter> 
<filter-name>characterEncodingFilter</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> 
</filter> 

<filter-mapping> 
    <filter-name>characterEncodingFilter</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 
+0

この設定はすでにweb.xmlに存在していますが、問題は残っていることを忘れています。 – Dave

+0

@Dave Boldbayar

関連する問題