2010.03.02 (2) - google map api with a page annotation

2010-04-19  来源:本站原创  分类:Java  人气:499 

2010.03.02 (2) - google map api with a page annotation

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> Simple paging  </title>
<script type="text/javascript" src="http://ditu.google.cn/maps?

file=api&amp;v=2&amp;key=ABQIAAAAMrMsJOafJ9iQiv3u_76UbBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQYvggBkgDawaMNCy_renoUB9_3FA&sensor=true_o

r_false"></script>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
// For AJAX requests and background
function fn5(start,number){
        $.ajax({
                type: "POST",
                url: "student_page.do",
                data: {start:start,number:number},
                dataType: "json",
                success: function(data){
                                        $.each(data,function(i,o){
                                                $("#tr"+(i+1)+" td:eq(0)").text(o["id"]);
                                                $("#tr"+(i+1)+" td:eq(1)").text(o["name"]);
                                                $("#tr"+(i+1)+" td:eq(2)").text(o["age"]);
                                        });

                                }
        });
}
$(function(){

        if(GBrowserIsCompatible()){// Judge browser compatibility
                var map = new GMap2(document.getElementById("map_canvas"));
                map.setCenter(new GLatLng(34.6156,112.4450),13);
                map.addControl(new GLargeMapControl());
                map.addControl(new GMapTypeControl());
                map.enableScrollWheelZoom();
                var str1 = "<div\"width:200px; height:220px;\"><table border=\"2\" bordercolor=\"red\" 

cellspacing=\"0\" align=\"center\" ><tr><td colspan=\"3\" align=\"center\"> Energy engineering  </td></tr><tr><td>ID</td><td> First name  

</td><td> Age  </td></tr><tr\"tr1\"><td></td><td></td><td></td></tr><tr\"tr2\"><td></td><td></td><td></td></tr><tr 

id=\"tr3\"><td></td><td></td><td></td></tr><tr\"tr4\"><td></td><td></td><td></td></tr><tr align=\"center\"><td 

colspan=\"3\"><input type=\"button\" value=\" Previous  \"\"\" />&nbsp;&nbsp;<input type=\"button\" value=\" The next page  \" 

onclick=\"\"/></td></tr></table></div>";
                var str2 = "<select><option> Beijing  </option><option> Tianjin  </option><option> Hebei  </option></select>";
                var marker = new GMarker(map.getCenter(),{title:" HA HA  "});
                map.addOverlay(marker);
                GEvent.addListener(marker,"click",function(latLng){
                        var str3 = " Longitude  : "+latLng.lng()+", Latitude  : "+latLng.lat();
                        marker.openInfoWindowTabsHtml([new GInfoWindowTab(" Label a  ", str1),new GInfoWindowTab(" Label b  ", str3)] 

);
                        fn5(0,4);
                });
        }
        $(window).unload(function(){
                GUnload();
        })
});
</script>
</head>
<body>
        <div></div>
</body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
        xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

  <servlet>
      <servlet-name>DispatcherServlet</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
       <init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>classpath:spring.xml</param-value>
       </init-param>
       <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>

      <servlet-name>DispatcherServlet</servlet-name>
      <url-pattern>*.do</url-pattern>
   </servlet-mapping>
</web-app>

spring.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:aop="http://www.springframework.org/schema/aop"
             xmlns:tx="http://www.springframework.org/schema/tx"
             xmlns:context="http://www.springframework.org/schema/context"
             xsi:schemaLocation="http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-

2.5.xsd"
            default-autowire="byName">
        <!--
        <aop:aspectj-autoproxy proxy-target-class="true"/>
        -->

        <!--  Database external file configuration   -->
    <bean>
                <property name="locations">
                        <list><value>classpath:db.properties</value></list>
                </property>
                <property name="fileEncoding" value="utf-8" />
        </bean>
    <!--  Database external file configuration   -->

    <!--  Configure the data source uses  dbcp Data source   -->
    <bean>
        <property name="driverClassName"
            value="${jdbc.driverClassName}" />
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
    </bean>

    <!--  Configure the data source uses  dbcp Data source   -->

    <!-- Hibernate SessionFactory Configuration   -->
    <bean
       >
        <property name="dataSource" ref="dataSource" />
        <property name="annotatedClasses">
            <list>
                <value>pojo.Student</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.OracleDialect
                </prop>
                <prop key="show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.use_sql_comments">true</prop>
            </props>
        </property>
        </bean>

        <!-- Hibernate SessionFactory Configuration   -->

        <!-- hibernateTemplate -->
        <bean>
            <property name="sessionFactory" ref="sessionFactory" />
        </bean> 

        <!-- hibernateTemplate -->

        <!-- dao -->
        <bean >
                <property name="hibernateTemplate">
                        <ref bean="hibernateTemplate" />
                </property>
        </bean>
        <!-- dao -->

        <!-- serice -->
        <bean >
                <property name="studentDao" >
                        <ref bean="studentDao" />
                </property>
        </bean>
        <!-- serice -->

        <!-- spring MVC -->
        <bean>
                <property name="studentService"><ref bean="studentService"/></property>
        </bean>

        <bean>
            <property name="methodNameResolver" ref="propMethodNameResolver"/>
            <property name="delegate" ref="studentDelegate"/>
        </bean>

        <bean>
                <property name="mappings">
                        <props>
                                <prop key="/student_*.do">studentController</prop>
                        </props>
                </property>
        </bean>

        <bean 

class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
        <property name="mappings">
            <props>
                <prop key="/student_page.do">page</prop>
                <prop key="/student_latLng.do">latLng</prop>
            </props>
        </property>
    </bean>

        <bean>
                <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
                <property name="prefix"><value></value></property>
                <property name="suffix"><value>.jsp</value></property>
                <property name="contentType"><value>text/html;charset=utf-8</value></property>
        </bean>
        <!-- spring MVC -->

</beans>

pojo

package pojo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="STUDENT")
public class Student {
        @Id
        @Column(name="student_id")
        private Integer id;
        private String name;
        private Integer age;
        public Integer getId() {
                return id;
        }
        public void setId(Integer id) {
                this.id = id;
        }
        public String getName() {
                return name;
        }
        public void setName(String name) {
                this.name = name;
        }
        public Integer getAge() {
                return age;
        }
        public void setAge(Integer age) {
                this.age = age;
        }

}

dao

package dao;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;

import pojo.Student;

public class StudentDaoImp implements StudentDao{
        private HibernateTemplate hibernateTemplate;

        public HibernateTemplate getHibernateTemplate() {
                return hibernateTemplate;
        }

        public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
                this.hibernateTemplate = hibernateTemplate;
        }

        public List<Student> page(final int start,final int number){
                return (List<Student>) this.hibernateTemplate.execute(new HibernateCallback(){

                        public Object doInHibernate(Session session)
                                        throws HibernateException, SQLException {
                                Query query = session.createQuery("from Student s order by s.id");
                                query.setFirstResult(start);
                                query.setMaxResults(number);
                                return query.list();
                        }

                });
        }
}

service

package service;

import java.util.List;

import pojo.Student;
import dao.StudentDao;

public class StudentServiceImp implements StudentService{
        private StudentDao studentDao;

        public StudentDao getStudentDao() {
                return studentDao;
        }

        public void setStudentDao(StudentDao studentDao) {
                this.studentDao = studentDao;
        }
        public List<Student> page(final int start,final int number){
                return this.studentDao.page(start, number);
        }
}

ctroller

package control;

import java.io.PrintWriter;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import org.springframework.web.servlet.ModelAndView;

import pojo.Student;
import service.StudentService;

public class StudentControl {
        private StudentService studentService;

        public StudentService getStudentService() {
                return studentService;
        }

        public void setStudentService(StudentService studentService) {
                this.studentService = studentService;
        }

        public ModelAndView page(HttpServletRequest request,
                        HttpServletResponse response) throws Exception {
                String start = request.getParameter("start");
                String number = request.getParameter("number");
                if(start==null) start = "0";
                if(number==null) number = "4";
                Integer s = 0;
                Integer n = 0;
                try{
                        s = Integer.parseInt(start);
                        n = Integer.parseInt(number);
                }catch(Exception e){
                        s = 0;
                        n = 4;
                }
                List<Student> students = this.studentService.page(s,n);
                PrintWriter out = response.getWriter();
                JSONArray json = JSONArray.fromObject(students);
                System.out.println(json.toString());
                out.print(json.toString());
                return null;
        }
}
相关文章
  • 2010.03.02 (2) - google map api with a page annotation 2010-04-19

    2010.03.02 (2) - google map api with a page annotation <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> &l

  • 2010.02.23 - google map api ---- Wuyue Jianpai drag annotation 2008-07-01

    2010.02.23 - google map api ---- Wuyue Jianpai drag annotation <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTM

  • 2010.02.21 - google map api ---- find the distance between two coordinates 2008-07-30

    2010.02.21 - google map api ---- find the distance between two coordinates GLatLng.distanceFrom (GLatLng )---- find the distance between two coordinates // According to the distance between two points is calculated longitude var distance = new GLatLn

  • 2010.02.22 - google map api ---- Weather Forecast 2008-10-27

    2010.02.22 - google map api ---- Weather Forecast Marker manager utility provides a program to address these issues, allowing the same map shows hundreds of high-performance tags, and be able to specify the zoom level tags should be displayed. To add

  • 2010.02.24 - google map api ---- custom map shows the boundary 2010-03-15

    2010.02.24 - google map api ---- custom map shows the boundary GLatLngBounds definition display border function initialize(){ if(GBrowserIsCompatible()){// Judge browser compatibility map = new GMap2(document.getElementById("map_canvas")); map.s

  • 2010.02.25 - google map api --- check the distance between the two places 2008-09-18

    2010.02.25 - google map api --- check the distance between the two places <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&

  • 2010.02.26 - google map api --- Polyline Polygon 2008-07-14

    2010.02.26 - google map api --- Polyline Polygon 1.GPolyline Polyline var map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(37, 107), 2); // Create GPolylineOptions argument as an object literal. // Note that we d

  • 2010.02.20 - google map 01 2010-02-13

    2010.02.20 - google map 01 index.jsp <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <tit

  • 2010.02.21 (2) - google map api ---- some pictures 2009-11-29

    2010.02.21 (2) - google map api ---- some pictures http://www.google.cn/mapfiles/marker?.png" Some address, can be A-Z In any case Note http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/examples/images/?.png http://gmaps-uti

  • Google map api 2010-03-29

    Last week, content: the use of GPS to obtain location and display the Google map. Are familiar with goole map of the api as well as some specific settings. google map api documentation for reference http://code.google.com/android/add-ons/google-apis/

  • 2010.03.02 - jquery in val, text, html, attr difference 2008-07-15

    2010.03.02 - jquery in val, text, html, attr difference 1.html () InnerHtml masses similar to javascript attributes that can be used to read or set the HTML content of an element in the For example: <p><strong>Hello world</strong></p&

  • 2010.03.02 (3) - jquery in $. Each (),$(). each () the difference between 2009-08-25

    2010.03.02 (3) - jquery in $. Each (),$(). each () the difference between $. each (obj, fn) A general iterative function can be used to approximate iterate objects and arrays. This function is $ (). Each () different ,$(). each () is designed for the

  • Google map api to use 2010-04-30

    google map api custom google map to support, can achieve a lot of features, while giving the example api is very comprehensive and very easy to use them. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtm

  • google map API respectively Marker coordinates before and after dragging 2010-06-07

    We know that using google map API to monitor the drag time marker, and drag-related events, a total of three: dragstart, drag, dragend, respectively, before the drag, drag in and drag the end of the corresponding event But no matter what kind of even

  • java how to use google map api V3 for address resolution. Reverse Address Resolution 2010-12-28

    google map api in the V3 version has been out for quite a while, but due to busy with work, so it has no time to Daoteng, recently looked at, the official said V2 can not be used quickly, suggesting to upgrade to the V3 version, so quickly learned bi

  • Google Map API with PHP to achieve positioning map login 2011-05-04

    Google Map API with PHP to achieve positioning main idea is to log user login system to record IP address, the address of the adoption of the relevant index to the physical address from the IP conversion, and finally through the Google Map API to obt

  • Development on google map api 2011-09-19

    Are trying to do a google map api to display the location of a few simple map navigation. Do not know how to start Check some information on the Internet: An application for google map key 2 http://code.google.com/intl/zh-TW/apis/maps/documentation/j

  • Google Map Api和GOOGLE Search Api整合实现代码 2014-03-25

    将GOOGLE MAP API 和 GOOGLE Search API 进行整合,我用面向对象的方式写了一个类,通过传一个经纬度进去,自动通过GOOGLE LOCAL SEARCH获取附近的相关信息.比如餐厅.景点等,反过来标到地图上,并可在任意容器内显示. 将GOOGLE MAP API 和 GOOGLE Search API 进行整合,我用面向对象的方式写了一个类,通过传一个经纬度进去,自动通过GOOGLE LOCAL SEARCH获取附近的相关信息.比如餐厅.景点等,反过来标到地图上,并可

  • Google Map API更新实现用户自定义标注坐标 2015-01-07

    由于工作需要,又要开始看Google Map API 代码,今天再把我之前的GoogleMap类,又更新了下,加了个简单的用户自定义标注坐标的功能.看看吧(代码没怎么优化,别见笑) 演示地址:http://www.yaohaixiao.com/effects/google-map.html if(typeof GoogleMap === 'undefined'){ var GoogleMap = {}; } (function(){ if (!document.getElementById("f

  • google map api query line 2010-02-06

    <% @ Page language = "java" import = "java.util .*" pageEncoding = "utf-8"%> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <title> Google maps API query line, in any location to any lo