所以,我在我的代码POST方法:JAVA API,汗布/ POST不工作
@POST
@Path("/send/{userPost}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public Response sendUser(@PathParam("userPost") String userPost) {
List<Post>userPosts = new ArrayList();
Post post = new Post(99,userPost,"Bartek Szlapa");
userPosts.add(post);
User user = new User(99,"Bartek","Szlapa",userPosts);
String output = user.toString();
return Response.status(200).entity(output).build();
}
遗憾的是它不工作。我得到404错误。服务器配置正确,因为其他方法完美工作。有趣的是,当我删除{userPost},参数:@PathParam(“userPost”)字符串userPost并发送空请求:http://localhost:8080/JavaAPI/rest/api/send它的工作原理 - 我得到新的用户对象在一些领域为null。你知道我为什么不能发送参数吗?预先感谢您的帮助! :)
什么是你想请求? –
http:// localhost:8080/JavaAPI/rest/api/send?= test – Bartos