gson - Why spring mvc automatically add GsonHttpMessageConverter? -


i want use gson in web application.when config gsonhttpmessageconverter in webconfig extend webmvcconfigureradapter,i found strang problem,that before add gsonhttpmessageconverter converters in extendmessageconverters,there 1 in converters,and 1 not have config date style. enter image description here why happen? want gsonhttpmessageconverter have date style "yyyy-mm-dd hh:mm:ss",how can it?

spring automatically creates gsonhttpmessageconverter if detects gson in classpath.

to customize converter creating own, can override following method in webmvcconfigurationsupport:

@override public void configuremessageconverters(list<httpmessageconverter<?>> converters) {     gson gson = new gsonbuilder().setdateformat("yyyy-mm-dd hh:mm:ss").create();     gsonhttpmessageconverter gsonhttpmessageconverter = new gsonhttpmessageconverter();     gsonhttpmessageconverter.setgson(gson);     converters.add(gsonhttpmessageconverter); } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -