使用spring rest插入数据库时发生了 前言中不允许有内容 错误

该错误一般是编码带来的问题,比如在请求post的时候,使用了application/x-www-form-urlencoded的content type

那么请求传过来的string则需要用urlDecoder进行decode。否则就会报上述错误

body = java.net.URLDecoder.decode(body, "UTF-8");
Source source = new StreamSource(new StringReader(body));

 

posted @ 2014-05-29 21:14  dorothychai  阅读(297)  评论(0编辑  收藏  举报