Recently done the project, there is a function is the cell phone attribution to query, because the project to run under the intranet, so can not be used to provide the webservice, had to find the Internet cell phone attribution of data, a lot of access, our project is to use Oracle, have to turn it, turn around to provide to the Internet, Convenient for everyone to use. The data is still relatively new, in 2014.
Here is some code, if you need all the code, you can download it directly.
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; @Autowiredpublic void Settabmobiledao (basedaoi<tabmobile> tabmobiledao) {This.tabmobiledao = Tabmobiledao;} @Overridepublic String Getmobilearea (Long mobilenumber) {//TODO auto-generated method stubstring 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 = "Mobileaction", results = {@Result (name = "Gomobile", location = "/ Wnl/mobile.jsp ")}) public class Mobileaction extends Baseaction implements Modeldriven<mobile>{private mobile Mobile = new Mobile ();p rivate tabmobileservicei tabmobileservice; @Autowiredpublic void Settabmobileservice ( Tabmobileservicei tabmobileservice) {this.tabmobileservice = Tabmobileservice;} @Overridepublic Mobile Getmodel () {//TODO auto-generated method Stubreturn 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>
All the code and database files please download here
http://download.csdn.net/detail/zyaizz/8145759
Local cell phone number attribution to query-oracle data