?? sightservlet.java
字號:
package com.oyc.mapxtreme.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.mapinfo.dp.Attribute;
import com.mapinfo.dp.Feature;
import com.mapinfo.mapj.MapJ;
import com.mapinfo.util.DoublePoint;
import com.oyc.mapxtreme.dao.SightDAO;
import com.oyc.mapxtreme.util.MapSearch;
import com.oyc.mapxtreme.util.RenderMap;
import com.oyc.wakeup.Session;
/**
* 旅游景點查找及顯示
* @author 三峽大學理學院 歐陽超
*
*/
public class SightServlet extends BaseHttpServlet {
/**
* 景點查找: 從數據庫中取出與關鍵字相似的景點
*
*/
public void searchSight(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//取得要查找的景點名稱關鍵字
String sightName = request.getParameter("sightName");
//創建DAO
Session sess = super.getWakeupSession();
SightDAO dao = new SightDAO(sess);
//查詢
List list = dao.searchSightByName(sightName);
sess.close();
int count = 0; //計算總數
if(list != null){
count = list.size();
}
request.removeAttribute("sightList");
request.setAttribute("sightList", list);
request.removeAttribute("sightCount");
request.setAttribute("sightCount", count+"");
String url = "sightList.jsp";
super.forward(url, request, response);
}
/**
* 在地圖上顯示某個景點
*
*/
public void showSight(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int sightID = Integer.parseInt(request.getParameter("sightID"));
//取出地圖對象
HttpSession sess = request.getSession();
MapJ myMap = (MapJ) sess.getAttribute("mapj");
//搜索
MapSearch mapSrh = new MapSearch();
try {
Feature feature = mapSrh.searchByAttribute(myMap, "景點", "sightID", new Attribute(sightID), null);
//重置重心
DoublePoint center = feature.getGeometry().getBounds().center();
myMap.setCenter(center);
} catch (Exception e) {
e.printStackTrace();
}
//渲染,輸出地圖
RenderMap render = new RenderMap();
try {
render.renderMap(myMap, response);
} catch (Exception e) {
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -