Illegal character - CTRL-CHAR

后端 未结 6 2225
野性不改
野性不改 2020-12-10 12:03

I am getting following exceptopn from webservices:

com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character ((CTRL-CHAR, code 15))

6条回答
  •  [愿得一人]
    2020-12-10 13:04

    Thanks guys for you inputs. I am sharing solution might be helpful for others. The requirement was not to wipe out CONTROL CHAR, it should remain as it is in DB also and one WS sends it across n/w client should able to get the CONTROL CHAR. So I implemented the code as follow:

    1. Encode strings using URLEncoder in Web-Service code.
    2. At client Side decode it using URLDecoder

    Sharing sample code and output bellow.
    Sample code:

    System.out.println("NewSfn");  
    System.out.println(URLEncoder.encode("NewSfn", "UTF-8"));  
    System.out.println(URLDecoder.decode("NewSfn", "UTF-8"));  
    

    Output:

    NewSfn  
    New%0FSfn  
    NewSfn 
    

    So client will recieve CONTROL CHARs.

    EDIT: Stack Exchange is not showing CONTROL CHAR above. NewSfn is like this New(CONTROL CHAR)Sfn.

提交回复
热议问题