学习笔记:获取XML数据,页面显示,实现详细信息与列表的联动效果

页面显示:
[code]
//加载数据岛
<xml id="xmldso_list" src="servlet/getXMLData"></xml>
<b>用户详细信息:</b>
<table bgcolor="#b5c7ef" style="font-size:12px;border:1px solid;width:80%">
<tr align="left"><th width="20%">帐号: </th><td id="td_account"></td><th width="20%">密码: </th><td id="td_password"></td></tr>
<tr align="left"><th>部门名称: </th><td id="td_deptName"></td><th width="20%">用户名称: </th><td id="td_username"></td></tr>
<tr align="left"><th>岗位名称: </th><td id="td_postName"></td><th width="20%">创建时间: </th><td id="td_createtime"></td></tr>
<tr align="left"><th>地址:</th><td id="td_Address"></td><th width="20%">备注: </th><td id="td_note"></td></tr>
</table>
<p><b>
用户列表:
</b><p><p><p></p>
<div style="width:80%;height:200px;overflow:scroll;border:1px #9DBCEA solid;">
<table datasrc="#xmldso_list" style="font-size:12px;" >
<thead>
<tr align="left"><th>帐号</th><th>部门名称</th><th>岗位名称</th><th>地址</th></tr>
</thead>
<tr align="left" onClick="testclick(this)" style="cursor: hand;"
οnmοuseοver="this.name=this.style.backgroundColor;this.style.backgroundColor='Honeydew';this.style.color='blue';" οnmοuseοut="this.style.backgroundColor=this.name;this.style.color='black'">
<td><div datafld="userAccount"></td>
<td><div datafld="deptName"></td>
<td><div datafld="postName"></td>
<td align="right"><div datafld="address"></td>
</tr>
</table>
</div>
[/code]
js脚本
[code]
<script type="text/javascript">
function testclick(field)
{
var row=field.rowIndex;
xmldso_list.recordset.absoluteposition=row;
td_account.innerHTML=xmldso_list.recordset("userAccount");
td_deptName.innerHTML=xmldso_list.recordset("deptName");
td_postName.innerHTML=xmldso_list.recordset("postName");
td_Address.innerHTML=xmldso_list.recordset("address");
td_password.innerHTML=xmldso_list.recordset("password");
td_username.innerHTML=xmldso_list.recordset("username");
td_createtime.innerHTML=xmldso_list.recordset("createtime");
td_note.innerHTML=xmldso_list.recordset("note");
}
</script>
[/code]
servlet获取数据
[code]public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

List users = this.getSysmrgAccess().getUserList();

response.setContentType("text/xml");
response.setCharacterEncoding("gb2312");

response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-cache");

PrintWriter out = response.getWriter();

out.println("<?xml version=\"1.0\" encoding=\"gb2312\"?>");
out.println("<users>");

for(int i=0;i<users.size();i++)
{
PermUserAccount user = (PermUserAccount) users.get(i);
out.println("<user>");
out.println("<userAccount>"+user.getUserAccount()+"</userAccount>");
out.println("<deptName>"+user.getDeptName()+"</deptName>");
out.println("<postName>"+user.getPostName()+"</postName>");
out.println("<address>"+user.getAddress()+"</address>");
out.println("<password>"+user.getPassword()+"</password>");
out.println("<username>"+user.getUserName()+"</username>");
out.println("<createtime>"+user.getCreateTime()+"</createtime>");
out.println("<note>"+user.getNote()+"</note>");
out.println("</user>");
}
out.println(" </users>");
out.flush();
out.close();
}[/code]

有啥意见尽管提,顺便作为学习笔记,免得以后忘了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值