如何在cxf webservice中获取请求参数

时间:2012-03-21 09:30:00

标签: java jax-ws cxf

我是cxf webservices的新手。

我有一个webservice类,我有一个方法可以通过html表单根据请求中的id发送来删除学生。

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

现在我的问题是,当我尝试以localhost/student/deleteStudent?studentId=abc

访问此网址时

我将studentId视为空字符串“”而不是“abc”。我做错了吗?

任何帮助都会非常有用。

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。我们应该在方法上使用@FormParam而不是@RequestParam来获取url中的参数值。

    @GET
    @Path( “/ deletestudent”)
    @Description(value =“删除已识别的学生”)
    public Response deleteStudent(
             @FormParam ( “studentId”)
            @Description(value =“要删除的学生ID”)
            final String studentId){

相关问题