If you need supporting HTML, in addition to JSON or XML then either return Response which already contains and HTML sequence or redirect to resources capable of wrapping response objects to HTML. Ex, if you have JSP or Velocity or some other servlet that can handle it then you need to use RequestDispatcherProvider to redirect:
http://cxf.apache.org/docs/jax-rs-redirection.html#JAX-RSRedirection-WithRequestDispatcherProvider I think I may need to do a demo. Alternatively use XSLTJAXBProvider: http://cxf.apache.org/docs/jax-rs-advanced-xml.html#JAX-RSAdvancedXML-XSLTsupport HTH Sergey On Thu, May 26, 2011 at 9:26 AM, gunanup <[email protected]> wrote: > Hi, > > How can we have an HTML format output for the JSON and XML > Content-Type, for example in the class below I have made annotation > @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) but the > result output should contatin the Content-type and output format is in html > format , do any one have an idea > > thanks > > @Path("/luckynumbers") > @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) > @Consumes({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) > public class CcmdServiceRESTFull{ > > > @GET > @Path("/getSum/{arg0}/{arg1}") > public Response getSum(@PathParam(value="arg0") int arg0 > ,@PathParam(value="arg1") int arg1,@Context HttpHeaders header) { > MediaType mediaType = header.getAcceptableMediaTypes().get(0); > String mediaStringType = > mediaType.getType()+"/"+mediaType.getSubtype(); > //return > Response.status(Response.Status.OK).type(mediaStringType).entity(Integer.toString(arg1+arg0)).build(); > > ResponseWrapper responseWrapper = new ResponseWrapper(); > responseWrapper.setTheResponse(Integer.toString(arg1+arg0)); > return responseWrapper.sendResponse(mediaStringType); > } > } > > > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/add-HTML-output-to-JSON-and-XML-tp4427885p4427885.html > Sent from the cxf-user mailing list archive at Nabble.com. > -- Sergey Beryozkin Application Integration Division of Talend http://sberyozkin.blogspot.com
