无法显示Json响应中的值

时间:2017-05-02 06:35:20

标签: angularjs jersey

我正在尝试使用hibernate从jersey web服务获取json web响应。当我在控制台中检查时,从数据库返回值。问题是当我尝试以像这样的角度打印时



<h1>Welcome to Hibernate Jersey Angular CMS</h1>
	<div id='err'></div>
	<a href="add.html" class='btn btn-success'>New Article</a>
	<p>
	<div>
		<table id='blogList' class="table table-bordered" ng-controller='MyController'>
			<tr>
				<th>Latest Articles</th>
				<th>Actions</th>
			</tr>
			<tr ng-repeat='elem in data'>
				<td>{{elem.id}}</td>
				<td><a class='btn btn-warning' href="modify.html?id={{elem.id}}">Modify</a></td>
			</tr>
		</table>
	</div>


</body>
<script src='javascripts/jquery2.1.3/jquery.min.js'></script>
<script src='javascripts/bootstrap3.3.2/js/bootstrap.min.js'></script>
<script src='javascripts/angular1.2.19/angular.js'></script>
<script src='javascripts/json/json2.js'></script>
<script>
	function MyController($scope, $http) {
		//$scope.data = [{title: 'welcome hello'},{title: 'great testing'}];

		$http.get("webapi/blog/list", {}).success(function(data, status, headers, config) {
			$scope.data = data;
		}).error(function(data, status, headers, config) {
			alert("error");
		})
	}
</script>

</html>
&#13;
&#13;
&#13;

不显示该值。它显示为空白 enter image description here

我知道我得到了正确的响应,因为图像的行数与表格中的条目数相同。这是我的hibernate代码

&#13;
&#13;
public List<Love> getAllLeaves() {
		Session session = HibernateTest.getSession();

		String hql = "from Love";
		Query qry = session.createQuery(hql);
		List<Love> list = qry.list();
		Iterator i=list.iterator();
		while(i.hasNext())
		{
			Love l=(Love) i.next();
			//System.out.println("staretd");
		}
		

		session.close();
		return list;
	}
&#13;
&#13;
&#13;

和球衣代码

&#13;
&#13;
@GET
	@Path("list")
	@Produces({ "application/json" })
	public List<Love> list() {
		List l= new LeaveDao().getAllLeaves();
		Iterator i=l.iterator();
		while(i.hasNext())
		{
			Love m=(Love)i.next();
			System.out.println(m.getLove());
		}
		
		return l;
	}
&#13;
&#13;
&#13;

和bean类

&#13;
&#13;
package com.king.entity;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.ws.rs.QueryParam;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
public class Love {
	public Love(String Love) {
		
		this.id = Love;
	}
	
	public Love()
	{}

	public String getLove() {
		return id;
	}

	public void setLove(String Love) {
		this.id = Love;
	}

	@Id
	@QueryParam("id")
	private String id;

}
&#13;
&#13;
&#13;

添加了网络响应

enter image description here

0 个答案:

没有答案