需要引入文件template-web.js
<script src="${pageContext.request.contextPath}/jq/template-web.js"></script>
<script>
$(function () {
$('button').click(function () {
$.get(
'${pageContext.request.contextPath}/check',
{},
function (res) {
console.log(res);
let json={
'check' : res
};
let html=template('result',json);
$('#box').append(html);
},
'json'
)
})
})
</script>
<body>
<h4>点击按钮查询用户信息</h4>
<button type="button" id="button">查询</button>
<div id="box"></div>
<script id="result" type="text/html">
<h5>以下是查询结果</h5>
{{each check as check}}
<p>uid:{{check.uid}}</p>
<p>用户名:{{check.nickname}}</p>
<p>邮箱:{{check.email}}</p>
<p>密码:{{check.password}}</p>
<p>性别:{{check.sex}}</p>
<p>城市:{{check.city}}</p>
<p>签名:{{check.sign}}</p>
{{if check.authority==true}}
<p>用户权限:管理员</p>
{{/if}}
{{if check.authority==false}}
<p>用户权限:普通用户</p>
{{/if}}
<p>注册时间:{{check.regtime}}</p>
<p>用户飞吻数:{{check.kissnum}}</p>
{{if check.isexsits==false}}
<p>用户状态:正常用户</p>
{{/if}}
{{if check.isexsits==true}}
<p>用户状态:隐藏用户</p>
{{/if}}
<p>=======================================</p>
{{/each}}
</script>
</body>
网友评论