How to handle special chars in parameter values?

前端 未结 3 712
闹比i
闹比i 2020-12-22 04:00

I\'ve some issues with my Java Servlet if it\'s called with special chars (like Æ, Ø og Å) in the GET-parameters: http://localhost:8080/WebService/MyService?test=Øs

3条回答
  •  时光说笑
    2020-12-22 04:36

    you should be percent encoding special characters (http://en.wikipedia.org/wiki/Percent-encoding). In your example above, the "slashed O" (Ø) has the UTF-8 code 0xd8, so your URL would properly be written:

    http://localhost:8080/WebService/MyService?test=%d8st.

    Which should result in

    Øst.
    

    being printed to the console, from your servlet code above.

提交回复
热议问题