jboss7 deployed to jboss server, Chinese garbled related problems

My problem is similar to the following

-------------------------------------------------

I encountered a problem in a recent project:

 

Problem scenario: server A and server B are managed by the same CAS, A sends a link containing Chinese characters to B, and Chinese characters are displayed in garbled characters when the webpage of system B is displayed.

Problem analysis: When A sends a link to B, because the user does not log in to the B system, the B system will be redirected to the CAS verification center, and the parameters will be re-encoded with URLEncode during the redirection process:

            "Chinese" urlencode is converted into %E4%B8%AD%E6%96%87

             After urlencode, it is converted into %25E4%25B8%25AD%25E6%2596%2587, which is equivalent to encoding "%" again.

 

Solutions to the above problems:

Encode Chinese with base 64, go to system B and then base 64 decoding (base64 urlSafeString encoding), the "%" problem is solved

But still garbled

Problem scenario:

Deploy the B system in the tomcat environment, and the Chinese characters are not garbled

Deploy the B system in the Jboss environment, Chinese garbled

Cause analysis: It may be a problem with the configuration of environmental parameters

Solution:

  • 修改jboss的bin/run.conf.bat    Add below code tofollowing  

                ::JAVA_OPTS_SET  set JAVA_OPTS=-Dfile.encoding="UTF-8"

  • How war is packaged with ant, and encoding needs to be specified when javac is used 

<target name="compile" depends="prepare">

  <javac srcdir="${src.java.dir}" destdir="${classes.dir}" debug="on" deprecation="on" optimize="off" includes="**/*.java" includeantruntime="false" encoding="UTF-8">

   <classpath refid="classpath" />

  </javac>

 </target>

problem solved.

 

Further reading:

http://www.blogjava.net/sandy/archive/2012/01/19/368747.html

http://yang3wei.github.io/blog/2013/02/10/java-dfile-dot-encoding-equals-utf-8-gan-diao-luan-ma/

 

 

But my changes are a little different

I changed the file to be standalone.bat and added after its set JAVA_OPTS: -Dfile.encoding=" UTF-8 "  

Problem solved.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326591457&siteId=291194637