1.control层
package com.nbesoft.company.control;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.nbesoft.company.service.AdOrderServiceI;
import com.nbesoft.company.service.PublicsAreaClassServiceI;
import com.nbesoft.framework.spring.BaseController;
import com.nbesoft.mapper.model.PublicsAreaClass;
@Controller
public class CityListControl extends BaseController{
//public
private static final long serialVersionUID = 1232852131083495065L;
@Autowired
private PublicsAreaClassServiceI areaClassService;
@Autowired
private AdOrderServiceI adOrderService;
@RequestMapping("/citylist")
public String cityList(HttpServletRequest request){
long AreaID = 0;
String rquestURL = request.getServerName();// "sz.szpxe.com";// request.getServerName();
if(rquestURL!=null && !"".equals(rquestURL.trim()) && rquestURL.contains(".")){
rquestURL = rquestURL.substring(0, rquestURL.indexOf("."));
}else{
rquestURL="www";
}
if (!rquestURL.equals("www")) {
PublicsAreaClass areaClass = areaClassService.findByOnlyAcronym(rquestURL);
if (areaClass != null) {
AreaID = areaClass.getAutoid();
}
}
//热门搜索
String hotKey= adOrderService.findByClassIDANDAreaID(38, AreaID);
if(hotKey!=null){
hotKey=hotKey.replaceAll("<p>","").replaceAll("</p>","").replaceAll("(class)[^>]*?\"[\\s\\S]*?\"|<font[^>]*?>|</font>|<span[^>]*?>|</span>|<strong>|</strong>","");//可能是分站
}else{
hotKey=adOrderService.findByClassIDANDAreaID(38,0).replaceAll("<p>","").replaceAll("</p>","").replaceAll("(class)[^>]*?\"[\\s\\S]*?\"|<font[^>]*?>|</font>|<span[^>]*?>|</span>|<strong>|</strong>","");//总站
}
request.setAttribute("hotKey", hotKey);
// 取出简称不为空的一级行政区域,根据GDP来排序
List<PublicsAreaClass> provinces = areaClassService.getProvinces();
request.setAttribute("provinces", provinces);
// 取出所有二级或以上的城市
List<PublicsAreaClass> listCity = areaClassService.getProvinceBeyond();
request.setAttribute("listCity", listCity);
return "citylist";
}
}
/***********************************************************************************************************/
2.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>全国分站地图 - 神州培训网</title>
<meta name="keywords" content="培训网点,神州培训网分站" />
<meta name="Description" content="神州培训网 全国十佳教育网站 搜培训 上神州培训网; 名校、名师、名课 学什么有什么!神州培训网 一切以为广大网友服务为中心,培训网 选 神州,神州培训网,实现你我梦想!" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="blank-translucent">
<link rel="shortcut icon" href="http://res.szpxe.com/res/html/news/Images/Icons/favicon.ico">
<link rel="stylesheet" href="http://res.szpxe.com/res/nvs/Style/reset.css">
<link rel="stylesheet" href="http://res.szpxe.com/res/nvs/Style/jihe.ui.css">
<link rel="stylesheet" href="http://res.szpxe.com/res/nvs/Style/index.css">
<script src="http://res.szpxe.com/res/nvs/Scripts/static/prefixfree.min.js"></script>
<script src="http://res.szpxe.com/res/nvs/Scripts/static/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
function matchCities(value){
$('.citylist-content a').each(function(){
if($(this).html()==$.trim(value)){
//location.href='#'+$(this).attr('id');
window.location.hash = '#'+$(this).attr('id');
$(this).focus();
if($(window).width()<1024){
$('header.ui-rel').hide();
setTimeout("$('header.ui-rel').fadeIn()", 5000);
}
$(this).css('background','yellow').animate({'fontSize':'32px'}).animate({'fontSize':'14px'});
setTimeout("$('#"+$(this).attr('id')+"').css('background','white')", 2000);
}
});
}
</script>
<!--[if lt IE 9]>
<script src="http://res.szpxe.com/res/nvs/Scripts/static/html5.js"></script>
<![endif]-->
<style type="text/css">
.citylist-content{
padding:20px;
}
.citylist-content a{
white-space:nowrap;
}
.course-attrs-val a{
font-size:13px;
}
@media screen and (max-width: 1024px){
.citylist{
width:100%;
}
.citylist-content{
padding:0 10px;
}
.wrapper{
top:50px;
}
.citylist-container h1:before{
display:none;
}
}
.m-t20{
margin-top:0;
}
</style>
</head>
<body>
<!-- 移动版菜单 -->
<%@ include file="include/m-navbar.jspf" %>
<!-- //End -->
<!-- 移动版用户信息 -->
<%@ include file="include/m-user.jspf" %>
<!-- //End -->
<!-- 顶部 -->
<%@ include file="include/topbar.jspf" %>
<!-- //End -->
<!-- 头部 -->
<%@ include file="include/header.jspf" %>
<!-- //End -->
<!-- 导航 -->
<%@ include file="include/navbar.jspf" %>
<!-- //End -->
<!-- 主体 -->
<div class="wrapper ui-rel">
<div class="ui-container m-t50">
<div class="course-attrs-item ui-sm-col2 ui-clear" style="padding-left:20px;">
<div class="course-attrs-val ui-l" data-pop="c" id="city_list">
<a href="http://www.szpxe.com/" target="_blank">总站</a>
<span> 省站:</span>
<c:forEach items="${provinces }" var="prov">
<a href="http://www.szpxe.com/s_${prov.onlyacronym }" target="_blank">${prov.classname }</a>
</c:forEach>
</div>
</div>
<!--
<span style="font-weight:bold; color:#494949;">热门城市入口</span><a style="color:#e63601;">>></a><a href="http://bj.szpxe.com/" target="_blank">北京</a><a href="http://sh.szpxe.com/" target="_blank">上海</a><a href="http://sz.szpxe.com/" target="_blank">深圳</a><a href="http://cq.szpxe.com/" target="_blank">重庆</a><a href="http://hz.szpxe.com/" target="_blank">杭州</a><a href="http://wh.szpxe.com/" target="_blank">武汉</a><a href="http://cd.szpxe.com/" target="_blank">成都</a><a href="http://xa.szpxe.com/" target="_blank">西安</a><a href="http://gz.szpxe.com/" target="_blank">广州</a><a href="http://nj.szpxe.com/" target="_blank">南京</a>
-->
<!-- 城市列表 -->
<div class="sidebar-col ui-l m-t20">
<div class="citylist">
<div class="citylist-search">
<form>
<input class="cls-text ui-l" type="text" placeholder="填城市,按回车" value="" οnkeyup="matchCities(this.value);" style="background:#FFF;color:#000;">
<input class="cls-btn ui-l ui-icon" type="submit" value="">
</form>
</div>
<section class="citylist-container">
<h1 class="swesome-icon">所有城市</h1>
<div class="citylist-content">
<c:set var="letters" value="${fn:split('a.b.c.d.e.f.g.h.j.k.l.m.n.p.q.r.s.t.w.x.y.z', '.')}"/>
<c:forEach items="${letters }" var="letter">
<dl>
<dt>${fn:toUpperCase(letter) }.</dt>
<dd>
<c:forEach items="${listCity }" var="city" varStatus="vs">
<c:if test="${fn:startsWith(city.onlyacronym, letter) }">
<a href="http://${city.onlyacronym}.szpxe.com/" target="_blank" id="city_${vs.index }"
<c:if test="${city.gdp>2000}">style="color: red" </c:if>
>${city.classname}</a>
</c:if>
</c:forEach>
</dd>
</dl>
</c:forEach>
</div>
</section>
</div>
</div>
<!-- //End -->
<!-- 右侧内容 -->
<div class="main-col ui-r m-hidden" data-ui-sticky="{direction:bottom,wrap:.ui-container}">
<style type="text/css">
#allmap{
height:990px;
width:910px;
}
@media screen and (max-width: 1280px) {
#allmap{
height:990px;
width:720px;
}
}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak=rcwsUQUl825zy2GkjIXCzxwk"></script>
<div id="allmap"></div>
<script type="text/javascript">
// 百度地图API功能
var map = new BMap.Map("allmap"); // 创建Map实例
map.centerAndZoom(new BMap.Point(118.795649, 31.937452), 6); // 初始化地图,设置中心点坐标和地图级别
map.addControl(new BMap.MapTypeControl()); //添加地图类型控件
map.setCurrentCity("南京"); // 设置地图显示的城市 此项是必须设置的
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
map.disableDoubleClickZoom();
map.addEventListener("click", function(e){
//alert(1);
});
map.addEventListener("dblclick", function(e){
$.ajax({
url: "http://api.map.baidu.com/geocoder/v2/?ak=rcwsUQUl825zy2GkjIXCzxwk&location="+e.point.lat+","+e.point.lng+"&output=json",
type: 'GET',
dataType: 'JSONP',
success: function (data) {
var city = data.result.addressComponent.city;
$('.citylist-content a').each(function(){
if($(this).html()==$.trim(city.substring(0, city.length-1))){
window.open($(this).attr('href'));
}
});
}
});
});
</script>
<!-- //End -->
</div>
<!-- //End -->
<!-- 工具条 -->
<%@include file="include/quick.jspf" %>
<!-- //End -->
</div>
<!-- 底部信息 -->
<%@ include file="include/footer.jspf" %>
<!-- //End -->
<!-- 底部辅助 -->
<%@ include file="include/footbar.jspf" %>
<!-- //End -->
</div>
<!-- //End -->
</body>
</html>