Change Tomcat's Charset.defaultCharset in windows

前端 未结 4 482
梦毁少年i
梦毁少年i 2020-12-03 03:06

I\'m using tomcat 6.0.32 in windows 7. Inside a very simple servlet, inside the init method, I\'m printing:

System.out.println(Charset.defaultCharset());


        
相关标签:
4条回答
  • 2020-12-03 03:47

    Try setting the (Windows) environment variable JAVA_TOOL_OPTIONS to -Dfile.encoding=UTF-8 and start the Tomcat Server.

    Will get more idea from this link: Setting the default Java character encoding

    0 讨论(0)
  • 2020-12-03 03:48

    You may also add this setting in the Tomcat 7.0 windows service manager.

    screenshot

    from Dr James Bayley's blog

    0 讨论(0)
  • 2020-12-03 03:53

    Just create a setenv.bat file inside the TOMCAT/bin directory with the following contents:

    set "JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF8"
    
    0 讨论(0)
  • 2020-12-03 04:09

    For Tomcat running as a Windows service neither %JAVA_OPTS% and neither setenv.bat answers works in my case.

    I set the option "-Dfile.encoding=UTF8" in registry:

    "HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\tomcatstackTomcat\Parameters\Java --> Options*

    Then it works.

    0 讨论(0)
提交回复
热议问题