DWR查询与填充Table
来源:互联网 发布:linux dracut 编辑:程序博客网 时间:2024/05/29 06:57
DWR查询与填充Table
首先去dwr官网下载一个dwr包.版本不一样.Web.xml中的配置也不一样(如下)此处为version: 2.0.M3
<servlet> <servlet-name>dwr-invoker</servlet-name> <servlet-class> org.directwebremoting.servlet.DwrServlet </servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dwr-invoker</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping>
下面JS回调方法(bean与联接数据库代码不在贴出.pubs库的employee表)
package com.guo.project.ajaxtm;
import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.util.*;
import com.guo.project.ajaxtm.Conn.GetConn;import com.guo.project.ajaxtm.po.Employee;
public class FillUserInfo { public Collection getInfo(String se) { System.out.println(se.equals("")+"se"+se.equals(null)); Collection list = new Vector(); String sql=""; if(!se.equals("")){ sql="select * from employee where minit=?";} else{ sql="select * from employee";} PreparedStatement ps=null; ResultSet rs=null; try { ps=GetConn.getconn().prepareStatement(sql); if(!se.equals("")){ ps.setString(1, se); } rs=ps.executeQuery(); Employee emp=null; while(rs.next()) { emp=new Employee(); emp.setEmp_id(rs.getString("emp_id")); emp.setFname(rs.getString("fname")); emp.setHire_date(rs.getString("hire_date")); emp.setJob_id(rs.getString("job_id")); emp.setLname(rs.getString("lname")); emp.setMinit(rs.getString("minit")); emp.setPub_id(rs.getString("pub_id")); list.add(emp); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(list.size()); return list; }} 接下来是dwr.xml配置如下<dwr> <allow> <create creator="new" javascript="FillUserInfo" scope="page"> <param name="class" value="com.guo.project.ajaxtm.FillUserInfo" /> <include method="getInfo"></include> </create> <convert converter="bean" match="com.guo.project.ajaxtm.po.Employee"> </convert> </allow></dwr>页面如下
<%@ page language="java" pageEncoding="GBK"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title></title> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <script type="text/javascript" src="dwr/interface/FillUserInfo.js"></script> <script type="text/javascript" src="dwr/engine.js"></script> <script type="text/javascript" src="dwr/util.js"></script> <script type="text/javascript"> function getmessage() { var se=this.frm.txt.value; this.frm.txt.value=""; FillUserInfo.getInfo(getdata,se); } function getdata(data) { ///DWRUril.setValue("info",dataUserName); var cellFuncs=[ function(data){return data.emp_id;}, function(data){return data.fname;}, function(data){return data.minit;}, function(data){return data.lname;}, function(data){return data.job_id;}, function(data){return data.pub_id}, function(data){return data.hire_date}/// function(data) { return "<input type='button' value='Test' onclick='alert(/"Hi/");'/>";} ]; DWRUtil.removeAllRows("demo1");///删除数据 DWRUtil.addRows("demo1",data,cellFuncs);///添加数据到TABLE } </script> </head> <body> <table> <tr> <td> <form name="frm" method="post"> <table> <tr> <td>标志查询:</td><td><input type="text" name="txt"/></td><td><input type="button" value="提交查询内容" onclick="getmessage();"/></td> </tr> </table> </form> </td> </tr> <tr> <td> <table width="545" height="32" border="1"> <thead> <tr> <th> 员工号 </th> <th> 姓 </th> <th> 标志 </th> <th> 名 </th> <th> 工号 </th> <th> 出版号 </th> <th> 日期 </th> </tr> </thead> <tbody id="demo1"> </tbody> </table> </td> </tr> </table> </body></html>
- DWR查询与填充Table
- BootStrap table 数据填充与分页
- 有关数据库查询与填充(通用方法)
- BootStrap table 数据填充与分页应用总结
- BootStrap table 数据填充与分页应用总结
- BootStrap table 数据填充与分页应用总结
- 使用DWR更新Table
- JavaScript Table行填充
- swing 填充表格Table
- table 添加行dwr.txt
- bootstrap table 整合dwr框架
- dwr 填充select 实现级联效果
- dwr异步查询简介
- C#填充Table的规则...
- DWR之与客户端的DWR交互
- DWR之与服务器端的DWR交互
- 闪回查询与闪回表(Flashback Query、Flashback Table)
- js进行操作table隐藏与显示查询
- struts高级,指令牌,上传组件,forwardaction,DispatchAction,DynaActionForm
- Dxperience8.1.1本地汉化
- Event Method Sequences when a Form is Opened
- enum类型的本质
- Oh! Boy! 天啊!
- DWR查询与填充Table
- 理解双指针
- 几条常见的数据库分页 SQL 语句(来源:Internet)
- Everyday English Learning
- 求助weblucene的安装部署问题
- 如何挑选适合自己的第一双单排鞋
- 与星期有关的短语
- 转: SPQuery查询语法简要说明
- “上大号”怎么说