首页 > 代码库 > 本地的手机号码归属地查询-oracle数据

本地的手机号码归属地查询-oracle数据

最近做的项目中,有个功能是手机归属地查询,因为项目要在内网下运行,所以不能用提供的webservice,只好在网上找手机归属地的数据,很多都是access的,我们的项目是用oracle,只好自己转吧,转过来的提供到网上,方便大家使用。数据还是比较新的,是2014年的。

下面是部分代码,如果需要全部代码,可以直接下载。

TabMobileServiceImpl.java

package com.zhouyu.service.impl;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import com.zhouyu.dao.BaseDaoI;import com.zhouyu.model.TabMobile;import com.zhouyu.service.TabMobileServiceI;@Service("tabMobileService")public class TabMobileServiceImpl implements TabMobileServiceI{	private BaseDaoI<TabMobile> tabMobileDao;	@Autowired	public void setTabMobileDao(BaseDaoI<TabMobile> tabMobileDao)	{		this.tabMobileDao = tabMobileDao;	}	@Override	public String getMobileArea(Long mobileNumber)	{		// TODO Auto-generated method stub		String area = "";		String hql = "from TabMobile m where m.mobileNumber = ‘"+mobileNumber+"‘";		List<TabMobile> list = tabMobileDao.find(hql);		if(list.size()>0)		{			area = list.get(0).getMobileArea() + "  --  " + list.get(0).getMobileType();		}		return area;	}}

 MobileAction.java

package com.zhouyu.action;import org.apache.struts2.convention.annotation.Action;import org.apache.struts2.convention.annotation.Result;import org.springframework.beans.factory.annotation.Autowired;import com.opensymphony.xwork2.ModelDriven;import com.zhouyu.pageModel.Mobile;import com.zhouyu.service.TabMobileServiceI;@Action(value = "http://www.mamicode.com/mobileAction", results = { @Result(name = "goMobile", location = "/wnl/mobile.jsp")})public class MobileAction extends BaseAction implements ModelDriven<Mobile>{	private Mobile mobile = new Mobile();	private TabMobileServiceI tabMobileService;	@Autowired	public void setTabMobileService(TabMobileServiceI tabMobileService)	{		this.tabMobileService = tabMobileService;	}	@Override	public Mobile getModel()	{		// TODO Auto-generated method stub		return mobile;	}		public String goMobile()	{		return "goMobile";	}		public void getArea() throws Exception	{		String area = tabMobileService.getMobileArea(mobile.getMobileNumber());		super.writeJson(area);	}}

mobile.jsp

<%@ page contentType="text/html; charset=utf-8"%><!DOCTYPE html><html><head><jsp:include page="../inc.jsp"></jsp:include><style type="text/css">.input {	width: 260px;	height: 30px;	font-size: 28px;	text-align:center;	border-top: 1px solid #404040;	border-left: 1px solid #404040;	border-right: 1px solid #D4D0C8;	border-bottom: 1px solid #D4D0C8;}.STYLE1 {	font-size: 36px;	color: #FF0000;}</style><script type="text/javascript">document.onkeyup=function(){	var s = document.getElementById("dd").value;		   document.getElementById("a").innerHTML= s		   if(s.length > 11)			{				document.getElementById("a").innerHTML= "输入的号码超出11位";			}	}	function testzy(obj)	{		obj.value = http://www.mamicode.com/obj.value.replace(/[^/d.]/g,"");		var d = $(‘#dd‘).val();		if(d.length == 7)		{			$.ajax({				type: "POST",//使用get方法访问后台或者post			    dataType: "json",//返回json格式的数据			    url: "mobileAction!getArea.action?mobileNumber="+d,//要访问的后台地址			    contentType: "application/x-www-form-urlencoded; charset=utf-8",			    success: function(data){//成功时会允许下面的函数,data为返回的数据,为数组类型			    	$("#cc").html(data);				}			});		}		if(d.length >7 && d.length <=11)		{			var str = d.substr(0,7);			$.ajax({				type: "POST",//使用get方法访问后台或者post			    dataType: "json",//返回json格式的数据			    url: "mobileAction!getArea.action?mobileNumber="+str,//要访问的后台地址			    contentType: "application/x-www-form-urlencoded; charset=utf-8",			    success: function(data){//成功时会允许下面的函数,data为返回的数据,为数组类型			    	$("#cc").html(data);				}			});		}		if(d.length > 11)		{			document.getElementById("a").innerHTML= "输入的号码超出11位";		}	}		function aaa()	{		$("#dd").val(‘‘);	}</script></head>  <body>	<h2>手机号码归属地查询</h2>    <input type="text" id="dd" class="input" onkeyup="testzy(this)" />    <input id="btn" type="button" value="http://www.mamicode.com/清空" onclick="aaa()" />    <span id="a" class="STYLE1"></span><br />    <div id="cc" class="STYLE1"></div></body></html>

  

 

全部代码及数据库文件请到这里下载

http://download.csdn.net/detail/zyaizz/8145759

 

本地的手机号码归属地查询-oracle数据