简体   繁体   English

如何在CXF Web服务中获取请求参数

[英]How to get request parameter in cxf webservice

I am new to the cxf webservices. 我是cxf Web服务的新手。

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. 我有一个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) {

Now my problem is this that when i try to access this url as localhost/student/deleteStudent?studentId=abc 现在我的问题是,当我尝试以localhost/student/deleteStudent?studentId=abc身份访问此URL时

I am getting studentId as empty string "" instead of "abc". 我正在将studentId作为空字符串“”而不是“ abc”。 Is i am doing something wrong? 我做错什么了吗?

Any help will be very helpful. 任何帮助都会非常有帮助。

I got this problem solved. 我解决了这个问题。 We should use @FormParam instead of @RequestParam on the method to get the parameter's value in the url. 我们应该在方法上使用@FormParam而不是@RequestParam,以在url中获取参数的值。

@GET @得到
@Path("/deletestudent") @Path(“ / deletestudentent”)
@Description(value="Delete the identified student") @Description(value =“删除已识别的学生”)
public Response deleteStudent( 公共响应deleteStudent(
@FormParam ("studentId") @FormParam (“ studentId”)
@Description(value="Student ID to delete") @Description(value =“要删除的学生ID”)
final String studentId) { final String studentId){

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM