【发布时间】:2014-02-19 07:13:00
【问题描述】:
我知道有关 jaxrs 参数的问题已被多次询问,并且对大多数事情都有很好的解释。但我找不到一个非常简单问题的答案。 如何在 post 请求中接收参数?
我的 Jax-RS 方法
@POST
@Path("data")
//@Consumes("application/json")
@Produces("application/json")
String getMobileServiceRepresentation(@PathParam("username") String username,@PathParam("password") String password) {
println username+":"+password
JSONObject obj=new JSONObject('{"dashboards": ["Dashbaord1","Dashboard2"]}')
obj
}
它打印null:null
我的请求是通过 curl ie
curl -X POST --data "username=username&password=pass" http://localhost:8080/blablaApp/api/mobileService/data
我也已经使用@Context UriInfo abc 来获取所有上下文参数。但没有找到运气
【问题讨论】: