Search code examples
javajax-wscxf

How to get request parameter in cxf webservice


I am new to the cxf webservices.

I have a webservice class in whihc i have a method to delete a student based on id send in request through a html form.

@GET
@Path("/deletestudent")
@Description(value="Delete the identified student")
public Response deleteStudent(@RequestParam("studentId") 
     @Description(value="Student ID to delete") final String studentId) {

Now my problem is this that when i try to access this url as localhost/student/deleteStudent?studentId=abc

I am getting studentId as empty string "" instead of "abc". Is i am doing something wrong?

Any help will be very helpful.


Solution

  • I got this problem solved. We should use @FormParam instead of @RequestParam on the method to get the parameter's value in the url.

    @GET
    @Path("/deletestudent")
    @Description(value="Delete the identified student")
    public Response deleteStudent(
                       @FormParam("studentId")
                       @Description(value="Student ID to delete")
                       final String studentId) {