NutzCN Logo
问答 跳转后页面打印出Json数据
发布于 2376天前 作者 wx_m34egglpcj6gvjmpmeh7 2041 次浏览 复制 上一个帖子 下一个帖子
标签:
	@At
	public Object query(@Param("name") String name, @Param("..") Pager pager) {
		Cnd cnd = Strings.isBlank(name) ? null : Cnd.where("name", "like", "%"
				+ name + "%");
		QueryResult qr = new QueryResult();
		qr.setList(dao.query(User.class, cnd, pager));
		pager.setRecordCount(dao.count(User.class, cnd));
		qr.setPager(pager);
		return qr; // 默认分页是第1页,每页20条
	}

	@At()
	@Ok("jsp:jsp.user.list")
	// 真实路径是 /WEB-INF/jsp/user/list.jsp
	public void index() {
	}
<a href="${base}/user/query" id="welcome"><input type="button" value="用户列表"></a>
12 回复
{"list":[{"id":1,"name":"admin","loginName":"王小三1","nickName":"吊炸天","age":27,"iphone":"12312312312"}, {"id":2,"name":"123","loginName":"123123","nickName":"吊炸天","age":8,"iphone":"12312312312"}, {"id":3,"name":"1234","loginName":"123","nickName":"吊炸天","age":12,"iphone":"12312312312"}, {"id":4,"name":"user","loginName":"asd","nickName":"吊炸天","age":23,"iphone":"12312312321"}, {"id":5,"name":"user1","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}, {"id":6,"name":"user2","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}, {"id":7,"name":"user3","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}, {"id":8,"name":"user4","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}, {"id":9,"name":"user5","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}, {"id":10,"name":"user6","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}, {"id":11,"name":"user7","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}, {"id":12,"name":"user8","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}, {"id":13,"name":"user9","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}, {"id":14,"name":"user10","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}, {"id":15,"name":"user11","loginName":"王小二","nickName":"吊炸天","age":22,"iphone":"18394467494"}],"pager":{"pageNumber":1,"pageSize":20,"pageCount":1,"recordCount":15}}

是我哪里配置的不对吗?

直接跳转jsp会显示页面

点击a标签后跳转,没毛病

@Ok("jsp:jsp.user.list")

@wendal 这个配置位置是不是错了

那个query方法是ajax调用的吧

@wendal 是的

function user_reload() {
		$.ajax({
			url : base + "/user/query",
			data : $("#user_query_form").serialize(),
			dataType : "json",
			success : function(data) {
// 				console.log(data);
				$("#user_count").html(
						"共" + data.pager.recordCount + "个用户, 总计"
								+ data.pager.pageCount + "页");
				var list_html = "<table border=\"1\"> <tr><th>编号</th><th>登录名</th><th>密码</th><th>用户名</th>"+
				"<th>昵称</th><th>年龄</th><th>电话</th><th>创建时间</th><th>修改时间</th><th>salt</th><th>修改</th><th>删除</th></tr>";
// 				console.log(data.list);
				for (var i = 0; i < data.list.length ; i++) {
					var user = data.list[i];
// 					console.log(user);
					var tmp = "<tr><td>" + user.id + "</td><td>" + user.name + "</td><td>"+user.password+"</td>" +
							"<td>" + checkNull(user.loginName) + "</td><td>" + checkNull(user.nickName) + "</td>" +
							"<td>" + checkNull(user.age) + "</td><td>" + checkNull(user.iphone) + "</td>" +
							"<td>" + user.createTime + "</td><td>" + user.updateTime + "</td>" + "<td>"+user.salt +"</td>"+
							"<td><button onclick='user_update(" + user.id +");'>修改</button></td>"+
							"<td><button onclick='user_delete(" + user.id +");'>删除</button></td>";
					list_html += tmp;
				}
				$("#user_list").html(list_html + "</table>");
			}
		});
	}

那你写个a标签干啥。。。

那跳到index方法不就好了

可以了,谢啦!!再看看文档吧

添加回复
请先登陆
回到顶部