jax-rs :使用 JQuery 从 Java 解析 ArrayList
我有一个从 CXF Rest 服务返回的 ArrayList,但我无法解析它以使用 JQuery 在客户端显示详细信息。
感谢任何帮助,
谢谢, 鲍勃
**Sample Code:**
This is how my code looks :
@GET
@Path("/{id}")
@Produces("application/json")
public Response getDetails(@PathParam("id") Long id) {
// data is retreied from database.
List<UserBO> userBOList = new ArrayList<UserBO>();
Response response = Response
.status(Response.Status.OK)
.entity(userBOList)
.build();
return response;
}
===================================================================
My Javascript code:
var url = "http://localhost:8080/user/1";
$("#submit").click(function(){
$.ajax({
type: "GET",
url: url,
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Origin","null");
},
contentType : "application/json",
dataType : "json",
success: function(data) {
alert( "Data Saved : " + data );
}
});
});
I have an ArrayList returned from my CXF Rest service, but I am unable to parse it to display the details on the client side using JQuery.
Appreciate any help
thanks,
Bob
**Sample Code:**
This is how my code looks :
@GET
@Path("/{id}")
@Produces("application/json")
public Response getDetails(@PathParam("id") Long id) {
// data is retreied from database.
List<UserBO> userBOList = new ArrayList<UserBO>();
Response response = Response
.status(Response.Status.OK)
.entity(userBOList)
.build();
return response;
}
===================================================================
My Javascript code:
var url = "http://localhost:8080/user/1";
$("#submit").click(function(){
$.ajax({
type: "GET",
url: url,
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Origin","null");
},
contentType : "application/json",
dataType : "json",
success: function(data) {
alert( "Data Saved : " + data );
}
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以像这样在 JavaScript 中循环遍历数组:
you can loop through an array in JavaScript like this: