If you have made a web-app using Spring, you should be gladly aware that you can pass the parameter using the annotation @RequestParam
But suppose you want to make a web-app with REST standards and you try using the @RequestParam object, you are more than likely to fail.
The JAX-RS doesn't support the @RequestParam.
You need to use @QueryParam
Shockingly Spring doesn't support @QueryParam...
So, how to mix both these things together, basically making a spring based web-app which follows JAX-RS standards..
Simple, apply both the annotations to the variable :D
Instead of defining the function like
Model getData(@QueryParam("username") String userName));
OR
Model getData(@RequestParam("username") String userName));
define the function as below
Model getData(@QueryParam("username") @RequestParam("username") String userName));
And you are done...!!
Hope that Spring and JAX-RS will break the ice soon....:D
I encountered the above problem when I was trying to generate documentation (api docs) for an application using enunciate....
And solved it pretty soon too...:)
No comments:
Post a Comment