Jboss 7 coding

I tried all possible answers of this and, but that did not work for me. Now write a question.

private String convertValue(String val){ System.out.println("convert input:" + val); String res = ""; StringTokenizer st = new StringTokenizer(val,","); while(st.hasMoreTokens()){ String token = st.nextToken(); if (token.matches("([0-9]*)")) { char c = (char)Integer.parseInt(token); res+=c; }else{ res+=token; } } System.out.println("convert output:" + res); return res; } 

When jboss 7 ends, it gives:

 convert input:61,1087,1088,1080,1074,1077,1090 convert output:= 

Running in jboss 7 action:

 convert input:61,1087,1088,1080,1074,1077,1090 convert output:=?????? 

Why is it not working properly?

My standalone.xml:

  <extension module="org.jboss.as.weld"/> </extensions> <system-properties> <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/> <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/> </system-properties> 

added java opts (-Dfile.encoding = UTF-8):

 convert input:61,1087,1088,1080,1074,1077,1090 convert output:=β€“ΓΈβ€”Γ„β€“βˆβ€“β‰€β€“Β΅β€”Γ‡ 

EDIT 1: My environment:

 Mac OS X Version 10.7.5 JBoss 7.1.1.Final java version "1.6.0_33" Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720) Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode) 

EDIT 2: The code snippet above works in javax.enterprise.context.RequestScoped back bean when a button is clicked on a JSF page.

+4
source share
2 answers

Try adding this to your standalone.conf file:

 JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8" 

This worked for me when the direct option for vm did not work.

+1
source

I don't have a Mac, but the related questions show that in your case, such code should work:

 private String convertValue(String val){ System.out.println("convert input:" + val); String res = ""; StringTokenizer st = new StringTokenizer(val,","); while(st.hasMoreTokens()){ String token = st.nextToken(); if (token.matches("([0-9]*)")) { char c = (char)Integer.parseInt(token); res+=c; }else{ res+=token; } } PrintStream out = new PrintStream(System.out, true, "UTF-8"); out.println("convert output:" + res); return res; } 
+1
source

Source: https://habr.com/ru/post/1444518/


All Articles