简体   繁体   English

使用Jax-R在RestApi调用上返回用户定义的类对象时出错

[英]Error returning a user defined class Object on RestApi call using Jax-Rs

Can any one help me in returning the user defined class objects using rest apis. 有谁能帮助我使用rest api返回用户定义的类对象。 That is on successful rest api call, return a user object. 那就是成功的REST API调用,返回一个用户对象。 I tried this 我试过了

@Path("/login")
@GET
//@Produces({MediaType.APPLICATION_JSON})
public User login(@QueryParam("username") String username, 
        @QueryParam("password") String password, 
        @QueryParam("org") String org)
{
    CometAppStack cs= new CometAppStack();
    User user= cs.loginUser(username, password, org);
    return user;
}

but getting an error saying 但出现错误提示

wrong number of arguments 错误的参数数量

Please help me. 请帮我。

The code seems alright, except you should un comment the line: @Produces 该代码似乎还不错,只是您应该取消对以下行的注释:@Produces

also if you can provide some more info of the code or configuration that will help. 也可以提供更多有关代码或配置的信息,这将有所帮助。

at what point the error is coming ? 在什么时候出现错误?

make sure you are calling the uri correctly and the names should match like: 确保您正确调用了uri,并且名称应匹配,例如:

https://hostname:port/login ? https:// hostname:port / login吗? username =abc& password =xyz& org =org 用户名 = abc& 密码 = xyz& org = org

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

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