【问题标题】:java web service get parameter while using post methodjava web服务在使用post方法时获取参数
【发布时间】:2017-09-14 04:40:35
【问题描述】:

我使用 GET 方法做了一个 java rest web 服务。该 web 服务使用 GET 方法可以正常工作。但是当我使用 POST 方法尝试它时,它不显示任何内容。 下面是我用 POST 方法测试它的简单代码。 请任何人帮助我解决这个问题。

@Path("/post")
public class Testpost {

    @POST
    @Path("/test")
    public String POST(@QueryParam("param") String msg) {
        String output = "POST:hELLO: "+msg;
        return output;
    }
}

【问题讨论】:

    标签: java web service


    【解决方案1】:
     public String POST(@QueryParam("param") String msg) {
    

    POST 不会有@QueryParam。它仅适用于 GET。

    对于 POST,您应该使用 @RequestParam

    【讨论】:

    • 你能把那个注释放在我的方法中并显示吗?这会很有帮助的。
    • post 方法仅在 SoapUI 上与 @QueryParam 一起使用。感谢您至少解决了我的问题并为我提供了一些解决问题的方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-11
    相关资源
    最近更新 更多