users@jersey.java.net

[Jersey] How to wrap controller result

From: 鲍鱼 <452537773_at_qq.com>
Date: Thu, 24 Jul 2014 11:41:50 +0800

Hi, all


    I want to wrap the normal controller result to a json structure‍. For example , if the controller return string "hello, world", then I will return {'code':0,'result':'hello,world'} to client. First I overwrite function "aroundWriteTo" in WriterInterceptor. But when the result is null or the return type of controller function is "void", ‍ function "aroundWriteTo" is not called. So how should I ‍realize this?‍‍


 Thanks.