problem description
A spring mvc project
does a very simple process
String test = "test"
write this string directly to the file
without adding any encoding type settings
running environment
run in win10 tomcat8 idea
premise
I have set the code used by the current project in idea to UTF-8
situation note
run the spring mvc project in idea, send a request through the browser, trigger the write operation
, and open the file with a tool, and it is found that it is encoded by gbk
then, I make a copy of the same project, open it with myeclipse, run it, and write a file in utf-8 format
.to further verify the problem, I created another springboot project, which runs in idea and myeclipse, respectively, and the resulting files are all in utf-8 format
.then, I test again, in the previous spring mvc project, add a unit test, write a file in the unit test, and the resulting file is in utf-8 format.
finally, I found that I have to set
in idea, in the configuration that starts tomcat.vm option : -Dfile.encoding=UTF-8
in this way, the written file is
in utf-8 format.sad questions
Why does this happen? I have set the coding mode of the whole project so that utf-8, does not seem to have any effect, but changing the Chinese in the code file to utf-8, does not make the operation of java itself execute according to this code, but the springboot project does not have this problem, and all myeclipse projects do not have this problem.
isn"t it true that if you deploy the war package of the project produced by idea to the server under win, you have to add a mandatory encoding format to the startup parameters? I haven"t tested this step yet. I"ll test it tomorrow.
Please give me some advice, thank you.