81,092
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
"http://www.getahead.ltd.uk/dwr/dwr10.dtd ">
<dwr>
<allow>
<create creator="new" javascript="CityMatch">
<param name="class" value="entity.CityMatch" />
</create>
<create creator="new" javascript="CityMatchDao">
<param name="class" value="dao.CityMatchDao" />
</create>
<create creator="new" javascript="CityMatchDaoImpl">
<param name="class" value="dao.impl.CityMatchDaoImpl" />
<include method="getCityMatch" />
</create>
</allow>
</dwr>
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>MyHtml.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.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>
</web-app>
package entity;
/**
* 落地码实体类
* @author 杜文俊
*/
public class CityMatch {
private String cityId;
private String name;
private String long_min;
private String long_max;
private String lat_min;
private String lat_max;
/** 下面是一堆 set、get 方法 */
}
package dao;
/**
* 落地码查询接口
* @author 杜文俊
*/
public interface CityMatchDao {
/**
* 落地码查询接口
* @param cityId
* @return List<CityMatch>
* @author 杜文俊
* @update 2014-5-6 下午1:25:15
*/
public List<CityMatch> getCityMatch(String cityId);
}
package dao.impl;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import dao.CityMatchDao;
import entity.CityMatch;
import util.ConnectionUtil;
/**
* 落地码查询接口实现类
* @author 杜文俊
*/
public class CityMatchDaoImpl extends ConnectionUtil implements CityMatchDao {
//数据库连接配置是单独写出去的 这里直接拿来用即可
private Connection con = null;
private Statement stmt = null;
private ResultSet rs = null;
@SuppressWarnings("static-access")
public List<CityMatch> getCityMatch(String cityId){
List<CityMatch> cityMatchList = new ArrayList<CityMatch>();
String sql = "select * from CITY_MATCH where CITY_ID = " + cityId;
try {
con = this.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()){
CityMatch cityMatch = new CityMatch();
cityMatch.setCityId(rs.getString("city_id"));
cityMatch.setName(rs.getString("name"));
cityMatch.setLong_min(rs.getString("long_min"));
cityMatch.setLong_max(rs.getString("long_max"));
cityMatch.setLat_min(rs.getString("lat_min"));
cityMatch.setLat_max(rs.getString("lat_max"));
cityMatchList.add(cityMatch);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
this.closeResultSet(rs);
this.closeStatement(stmt);
this.closeConn(con);
}
return cityMatchList;
}
}
<!DOCTYPE html>
<html>
<head>
<title>the test page</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type='text/javascript' src='/ZTWeb/dwr/interface/CityMatchDaoImpl.js'></script>
<script type='text/javascript' src='/ZTWeb/dwr/interface/CityMatchDao.js'></script>
<script type='text/javascript' src='/ZTWeb/dwr/interface/CityMatch.js'></script>
<script type='text/javascript' src='/ZTWeb/dwr/engine.js'></script>
<script type='text/javascript' src='/ZTWeb/dwr/util.js'></script>
<script language="javascript">
function callTestCityMatch(){
alert("45600000");
CityMatchDaoImpl.getCityMatch("152224");
}
</script>
</head>
<body>
the test form
</br>
<form action="post">
<table border=1>
<tr>
<td colspan="3">传递参数:<input id="resid" type="text" value="" /></td>
<td colspan="3"><input type="button" value=" 查 询 " onclick /></td>
</tr>
<tr>
<td>编号</td>
<td>名称</td>
<td>最小经度</td>
<td>最大经度</td>
<td>最小纬度</td>
<td>最大纬度</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a<input type="button" value="aaa" name="button3"
onclick="test('012345')"></td>
</tr>
</table>
</form>
</body>
</html>