简体   繁体   中英

spring mvc json array values are converted to &#034

I have this in my spring project

@RequestMapping(value = "/show", method = RequestMethod.GET)
public String view(ModelMap request, @RequestParam("items") String Items){
    System.out.println(Items);
}

Prints the below json

{
"items":[
  {
    "price":30
  },
  {
    "price":"50"
  }
 ]
}

but when I pass the above json data to JSP file it converts to this

{"items":[{"Price&#034:"30"},{"Price":"50"}]}

How to decode this so I can display properly in my view? And btw the above req param I am getting is encoded url JSON.

Your double quotes get converted to this &#034 HTML ASCII because you are not using escape characters. You can use \" (escape character, to pass double quotes as it is.).
forex.

String jsonData = "{ \"key\" : \"value\" }";

Or you can use a library such as Jackson to Parse your JSON for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM