A
A
Andrey Myvrenik2016-05-29 20:18:53
Java
Andrey Myvrenik, 2016-05-29 20:18:53

Is it possible to change the output of @NotNull from "text/plain" to "application/json" in JAX-RS?

Let's say we have a JAX-RS REST service with the following method:
a94b6af6f5d64d2d838070c6669e3f69.png
The member parameter is validated against null using the NotNull annotation . If you make a POST request with an empty body, the server will return a 400 response, which is logical, but in the response body it writes automatically generated additional error information in text/plain format.
988f00e16adb452abaecd8108d0ca3fd.png
Actually the question is, is it possible to change the format of the generated information to JSON and how to do it? Why does it basically return text/plain by default, and not what is specified in the parameters of the Produces annotation to the method?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2016-05-30
@zolt85

Here is what is written in the encyclopedia of young marmots

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question