Optional @PathParam in Jax-RS for format .json .xml -


I have a service using java in jersey , now I mapping the following three URLs I want a single method, so Json any function .json or .xml output the converted accordingly if not granted an extension (format) default returns

Code code works fine but if not specified .xml or .json url is not found

  / api / getData (result is js on) is /api/getData.json (results json) Please note that I can not change it  
  / api / getData / xml / api / getData / to  < / pre> 

Jason

I to functionName.format

  @ POST @Path ( "/ getData {format } @ Product ({MediaType.APPLICATION_XML}, MediaTypeP.OPPLICANGSNS}} public response (@formamaram ("token") string token, @ pathpram ("format") string format, @contact httpttervate request contact) { ....}  

You need to add a wildcard to support non-extension requests with a resource the sign, like:

{[pathParamName]: ([permissions]] [wildcard sign]} -> {ext: (.json | .xml) *}

Example:

  @GET @ Path ( "foo / {time} { ext :(. Json | .xml) *} "@Produces ({MediaType.APPLICATION_JSON, Meediataip.apeepielaisiadi_aksmel}) public get synchronized Response Avents (@ Pathprm (" once ") string time, @PathParam (" ext ") string ext ) {If (". Equals (ext)) ext =" .json "; println (bar); println (ext); // return return;}  

a good The days are ...


Comments