Here's the situation:
- I have RESTEasy and Jackson working together beautifully
- My RESTful classes implement ExceptionMapper and have a toResponse method on them.
- If I have a problem inside any of my RESTful methods an Exception is thrown and caught by the toResponse method.
- I'd like the exception to turn into nicely formatted XML or JSON (depending on the Accept header)
The problem is I have no idea what the Accept header is inside the toResponse method. I know I can extend the Exception class and pass the header in as a variable, which I can then use in toResponse, but I was hoping there would be a more 'correct' way to do this. I've tried adding the @Produces annotation to the toResponse method without success.
Has anyone successfully configured RESTEasy to easily return JSO开发者_StackOverflow中文版N or XML from toResponse?
-Dan
Nevermind, I found the answer. I must have worded my question poorly, but I will leave this around in case someone stumbles upon it.
Here's the answer: JAX-RS (Jersey) custom exception with XML or JSON
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论