Friday, 12 September 2014

Strip non utf-8 from xml data before @RequestBody see's it



I'm being sent (bad) xml which I have no control over, It’s supposed to contain only UTF-8 characters but some of the data text isn’t. When it passes through Spring's @Requestmapping / @ResponseBody processing methods I correctly, get unmarshalling errors.


I would like to strip the bad characters - I could use a servlet filter and replace bad characters with '?'. My question is there a trivial way to do this with Spring, setting content type etc (I seem to think these are just selectors rather than active agents) - I'd hate to find out after I built an interceptor I could have done something really trivial. Any ideas.


No comments:

Post a Comment