0

Hi I've been checking lots of posts already but I havent found the problem that's happening with me. My PathParam always is null, can anyone tell me what might be the issue

Imports in interface:

import javax.servlet.http.HttpServletRequest; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; 

Interface:

@RequestMapping(value="/unhash/{hash}", method = RequestMethod.GET) @Produces({ MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @ResponseBody Token decryptToken(@PathParam("hash") String token, HttpServletRequest request) throws APIException; 

And the implementation:

@Override public Token decryptToken(String token, HttpServletRequest request) throws APIException { 

I seen nothing strange here, it's working fine for queryparams. Any ideas? I am of confuse.

4
  • 1
    Why are you mixing Spring with JAX-RS annotations? Which one are you really trying to use? Commented Nov 13, 2015 at 14:47
  • If you're trying to use JAX-RS, remove @ResponseBody, remove @RequestMapping, add @GET and use @Path("/unhash/{hash}"). If you're trying to use Spring, get rid of @PathParam and use @PathVariable. and get rid of @Produces, and add produces in the @RequestMapping annotation. Commented Nov 13, 2015 at 14:49
  • Allright I'll try that, I'm indeed using spring. Commented Nov 13, 2015 at 14:55
  • I would probably get rid of all the JAX-RS dependencies if you're not going to use them, so you don't get confused Commented Nov 13, 2015 at 15:02

1 Answer 1

1

How you are calling your service and why you are sending HttpServletRequest parameter? I implemented your scenario using Jersey without HttpServletRequest. And i called service with service/unhash/xxx. It is works fine.

@Path("/service") public class MyFirstRestService implements Rest { @Override public Response decryptToken(String token) throws Exception { // TODO Auto-generated method stub String output="It is success- Path Pram : "+ token; return Response.ok(output).build(); } 

Rest.class :

public interface Rest { @GET @Path(value="/unhash/{hash}") @Produces({ MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) Response decryptToken(@PathParam("hash") String token) throws Exception; } 

go to http://www.javawebservice.com for more information and example

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.