How to serialize Java primitives using Jersey REST

前端 未结 6 1972
灰色年华
灰色年华 2020-11-29 11:47

In my application I use Jersey REST to serialize complex objects. This works quite fine. But there are a few method which simply return an int or boolean.

Jersey can

6条回答
  •  情话喂你
    2020-11-29 12:14

    I've just discovered that returning a primitive type with Jersey is problematic. I've decided to return String instead. Maybe this is not clean, but I don't think it's too dirty. The Java client, which is written by the same author of the server most of the times, can wrap such a string return value and convert it back to int. Clients written in other languages must be aware of return types any way.

    Defining RestInteger, RestBoolean may be another option, however it's more cumbersome and I see too little advantage in it to be attractive.

    Or maybe am I missing something important here?

提交回复
热议问题