- 浏览: 82020 次
- 性别:
- 来自: 深圳
-
文章分类
- 全部博客 (98)
- Linux (6)
- vsftpd vsftp ftp (2)
- perl flock (1)
- ajax (1)
- highcharts (1)
- http://www.bejson.com/knownjson/webInterface/ (1)
- mysql (1)
- iOS研究框架之SDwebimage原理 (1)
- oepn ssl (1)
- mysql插入时间戳列 (1)
- mysql pool (1)
- gsoap (1)
- VS (1)
- angular http jsonp (1)
- NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL (1)
- http://www.cnblogs.com/madyina/p/5970814.html (1)
- 批量生成各尺寸的iOS图标 (1)
- Ionic2 Rest 认证 (1)
- 反编译工具 IDA (1)
- formbuilder (1)
- asp.net com 80040154 Class not registered (1)
- angular2-highcharts用法详解 (1)
- 儿童教育资源 (1)
- Accordion List with Ionic (1)
- 清华附小权威老师推荐详细书单 (0)
- android (1)
- Hexadecimal -> file (binary) (1)
- open ssl (1)
- swift apple (1)
- 常见网址 (0)
- Charles4.2.5 (1)
- swift link (1)
- 域名 空间申请 (0)
- 常见网址 免费主机 (1)
- 最详细的美国旅游签证办理流程 (1)
- 公司办理美国签证流程 (0)
- link (1)
- 楼市 (0)
- inatall uml (1)
- 信用卡 (0)
- net use 共享 删除 (1)
- perl ftp (1)
- cron (1)
- 2018 self evauation (0)
- upload by ftp linux script (1)
- 青少年学习 (1)
- Shell脚本交互之:自动输入密码 (1)
- 通过ffmpeg实现视频流截图 (1)
- Discuz论坛迁移--数据库配置文件 (1)
- ELK(ElasticSearch (1)
- Logstash (1)
- Kibana)搭建实时日志分析平台 (1)
- 阿里面试题目目录 (1)
- network-attached storage (NAS) (1)
- jar (1)
- PostgreSQL操作-psql基本命令 (0)
- PostGreSQL (1)
- 百度网盘资源搜索 (1)
- git command (1)
- log4perl MinGW Dev C++ (1)
- perl 自定义模块 (1)
- 使用virt-manager安装和管理虚拟机 (1)
- ActivePerl5.14 (1)
- servicenter (1)
- 民国货币 (0)
- 物价变迁 (0)
- 历年养老金涨幅 (1)
- 1987年北京物价 (1)
- 金融业总资产 (1)
- 中国通史 (0)
- How to change @INC to find Perl modules in non-standard locations (1)
- ruby on rails (1)
- win10 ruby (1)
- Sybase isql常用命令 (1)
- php开发环境搭建 (1)
- check_Radius_Account.php (1)
- SymmetricDS (1)
- Kotlin Eclipse 环境搭建 (1)
- 基于SpringBoot搭建应用开发框架 基于SpringBoot-Dubbo的微服务快速开发框架 (1)
- 架构师技术图谱,助你早日成为架构师 (1)
- Java并发编程:volatile关键字解析 (1)
- MySQL 表锁和行锁机制 (1)
- IntelliJ IDEA 2018激活码 永久破解 (0)
- 基于 Javassist 和 Javaagent 实现动态切面 (1)
- JAVA必背面试题和项目面试通关要点(带答案) (1)
- Hadoop分布式集群的搭建 (1)
- navicat112_premium (0)
- snmp trap (1)
- net snmp linux (1)
- net snmp trap (1)
- install wmi in linux (1)
- vidyard (0)
- compare file content (1)
- XINETD TCP echo service (1)
- 从页面获取form表单提交的数据 (1)
- thymeleaf 分页 级联 (1)
- Apache log4j2 远程命令执行漏洞复现及修复方案 (1)
- win7 瘦身 (0)
最新评论
Thymeleaf 分页功能
https://www.iteye.com/blog/gjp014-2387037
Thymeleaf select 使用 和多select 级联选择
https://www.iteye.com/blog/gjp014-2395655
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.w3.org/1999/xhtml" layout:decorator="thymeleaf/templates/layout.html">
<head>
<script type="text/javascript" th:src="@{/js/sgo/endpoint.js}"></script>
<title>Endpoint Form</title>
</head>
<body>
<div layout:fragment="content">
<form action="#" id="endpoint-form" th:object="${endpointForm}" method="post"
th:action="@{/{deviceAction} (deviceAction=${endpointForm.id == null ? 'add-endpoint.mvc' :'endpoints/'+endpointForm.id+'/updateendpoint.mvc'})}" >
<input th:type="hidden" th:field="*{id}" th:if="${endpointForm.id != null}" />
<div th:if="${#fields.hasErrors('*')} or ${resultList != null}" class="alert alert-danger" role="alert">
<ul>
<li th:each="e : ${#fields.detailedErrors()}" th:class="${e.global}? globalerr : fielderr">
<span th:text="${e.global}? '*' : ${e.fieldName}">The field name</span> -
<span th:text="${e.message}">The error message</span>
</li>
<li th:each="r : ${resultList}" th:class="globalerr">
<span th:text="'*'">The field name</span> -
<span th:text="${r.getMessage()}">The error message</span>
</li>
</ul>
</div>
<div th:if="${success != null}" class="alert alert-success" role="alert" th:text="${success}" />
<div class="form-group" th:name="endPointName" th:errorclass="has-error">
<label class="control-label" th:for="endPointName">Endpoint Name <span class="glyphicon glyphicon-asterisk"></span></label>
<input type="text" th:field="*{endPointName}" class="form-control required" id="endPointName"/>
</div>
<div class="row-fluid col-md-12">
<div class="form-group col-md-2" th:name="EPSTypeID" th:errorclass="has-error">
<label class="control-label" th:for="EPSTypeID">Endpoint Type Id <span class="glyphicon glyphicon-asterisk"></span></label>
<select size ="5" th:field="*{EPSTypeID}" class="form-control" id="EPSTypeID">
<option th:each="epsTypes : ${epsTypes}"
th:value="${epsTypes.id}"
th:text="${epsTypes.name}">Endpoint Type Id</option>
</select>
</div>
<div class="form-group col-md-2" th:name="msoId" th:errorclass="has-error" >
<label class="control-label" th:for="msoId">MSO Id <span class="glyphicon glyphicon-asterisk"></span></label>
<select size ="5" th:field="*{msoId}" class="form-control" id="msoID">
<option th:each="mso : ${mso}"
th:value="${mso.id}"
th:text="${mso.name}">MSO Id</option>
</select>
</div>
</div>
<!--div class="row-fluid col-md-12">
<div class="form-group col-md-2" th:name="city" th:errorclass="has-error">
<label class="control-label" th:for="city">City <span class="glyphicon glyphicon-asterisk"></span></label>
<input type="text" th:field="*{city}" class="form-control required" />
</div>
<div class="form-group col-md-2" th:name="state" th:errorclass="has-error" >
<label class="control-label" th:for="state">State </label>
<input type="text" th:field="*{state}" class="form-control required" />
</div>
<div class="form-group col-md-2" th:name="province" th:errorclass="has-error" >
<label class="control-label" th:for="province">Province </label>
<input type="text" th:field="*{province}" class="form-control required" />
</div>
<div class="form-group col-md-2" th:name="country" th:errorclass="has-error" >
<label class="control-label" th:for="country">Country <span class="glyphicon glyphicon-asterisk"></span></label>
<input type="text" th:field="*{country}" class="form-control required" />
</div>
</div-->
<div class="row-fluid col-md-12">
<div class="form-group col-md-2" th:name="country" th:errorclass="has-error" >
<label class="control-label" th:for="country">Country <span class="glyphicon glyphicon-asterisk"></span></label>
<select size ="5" th:field="*{country}" class="form-control" name="startArea1" id="start_select1">
<!--option value="">Choose Country</option-->
<option th:each="country:${country}" th:value="${country.id}" th:text="${country.name}" ></option>
</select>
</div>
<div class="form-group col-md-2" th:name="state" th:errorclass="has-error" >
<label class="control-label" th:for="state">State </label>
<select size ="5" class="form-control" th:field="*{state}" name="startArea3" id="start_select3">
<!--option value="">Choose State</option-->
<option th:each="state : ${state}"
th:value="${state.id}"
th:text="${state.name}">State</option>
</select>
</div>
<div class="form-group col-md-2" th:name="province" th:errorclass="has-error" >
<label class="control-label" th:for="province">Province </label>
<!--select class="form-control" name="startArea2" id="start_select2">
<option value="">Choose Province</option>
</select-->
<select size ="5" class="form-control" th:field="*{province}" id="start_select2">
<option th:each="province : ${province}"
th:value="${province.id}"
th:text="${province.name}">Province</option>
</select>
</div>
<div class="form-group col-md-2" th:name="city" th:errorclass="has-error">
<label class="control-label" th:for="city">City <span class="glyphicon glyphicon-asterisk"></span></label>
<select size ="5" class="form-control" th:field="*{city}" name="startArea4" id="start_select4">
<!--option value="">Choose City</option-->
<option th:each="city : ${city}"
th:value="${city.id}"
th:text="${city.name}">City</option>
</select>
</div>
</div>
<div class="form-group" th:name="timezoneName" th:errorclass="has-error">
<label class="control-label" th:for="TimezoneID">Timezone <span class="glyphicon glyphicon-asterisk"></span></label>
<input type="text" th:field="*{timezoneName}" class="form-control required" id="timezoneName"/>
</div>
<button type="submit" class="btn btn-sm btn-primary" id="endpoint-submit" th:text="${endpointForm.id == null ? 'Create' : 'Update'}">Create</button>
<a th:href="@{{deviceAction} (deviceAction=${endpointForm.id == null ? 'endpoints.mvc' :'/endpoints/'+endpointForm.id+'/devices.mvc'})}" title="Cancel" class="btn btn-sm btn-primary">Cancel</a>
</form>
</div>
</body>
</html>
$(document).ready(function() {
$('#endpoint-form')
.on('change','#start_select1', function() {
//.on('change','#country', function() {
let countryid = $("#start_select1").val();
$.getJSON( "/" + contextRoot + "/provinces-json.mvc?id="+countryid, function( data ) {
let items = [];
$.each( data, function( key, value ) {
console.log(value);
items.push( "<option value='" + value.id + "'>" + value.name + "</option>" );
});
$('#start_select2').html(items.join(""));
});
$.getJSON( "/" + contextRoot + "/states-json.mvc?id="+countryid, function( data ) {
let items = [];
$.each( data, function( key, value ) {
console.log(value);
items.push( "<option value='" + value.id + "'>" + value.name + "</option>" );
});
$('#start_select3').html(items.join(""));
});
$('#start_select4').html("");
document.getElementById("timezoneName").value ="";
})
.on('change','#start_select2', function() {
//.on('change','#province', function() {
let provinceID = $(this).val();
let stateID = 0;
let countryid = $('#start_select1').val();
$.getJSON( "/" + contextRoot + "/cities-json.mvc?id="+countryid+"&provinceID="+provinceID+"&stateID="+stateID, function( data ) {
let items = [];
$.each( data, function( key, value ) {
console.log(value);
items.push( "<option value='" + value.id + "'>" + value.name + "</option>" );
});
$('#start_select4').html(items.join(""));
});
})
.on('change','#start_select3', function() {
//.on('change','#state', function() {
let stateID = $(this).val();
let provinceID = 0;
let countryid = $('#start_select1').val();
$.getJSON( "/" + contextRoot + "/cities-json.mvc?id="+countryid+"&provinceID="+provinceID+"&stateID="+stateID, function( data ) {
let items = [];
$.each( data, function( key, value ) {
console.log(value);
items.push( "<option value='" + value.id + "'>" + value.name + "</option>" );
});
$('#start_select4').html(items.join(""));
});
})
.on('change','#start_select4', function() {
//.on('change','#city', function() {
let cityID = $(this).val();
$.getJSON( "/" + contextRoot + "/timezone-json.mvc?cityID="+cityID, function( data ) {
if(data !=null){
console.log(data.name);
//$('#timezoneName').html(data.name);
document.getElementById("timezoneName").value = data.name;
}
//let items = [];
//$.each( data, function( key, value ) {
//console.log(value);
//items.push( "<option value='" + value.id + "'>" + value.name + "</option>" );
// });
//$('#timezoneName').html(items.join(""));
});
})
.on("click","#endpoint-submit",function(e) {
e.preventDefault();
confirmAdd(dataToParams($('#endpoint-form').data(),$(this).data()));
});
});
@RequestMapping(value = "/provinces-json", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public List<Province> getProvinceInJSON(@RequestParam(value="id", required = false) Long countryID,
@PageableDefault(sort = "model.model", direction = Sort.Direction.ASC) Pageable pageable,
Model model, HttpServletRequest request, HttpSession session) {
List<Province> province;
logger.info("get province,countryID:"+ countryID);
if (countryID != null) {
province = provinceRepository.searchByCountryIdAndFetchProvince(countryID);
}else{
province = null;
}
return province;
}
@RequestMapping(value = "/states-json", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public List<State> getStateInJSON(@RequestParam(value="id", required = false) Long countryID,
@PageableDefault(sort = "model.model", direction = Sort.Direction.ASC) Pageable pageable,
Model model, HttpServletRequest request, HttpSession session) {
List<State> state;
logger.info("get state,countryID:"+ countryID);
if (countryID != null) {
state = stateRepository.searchByCountryIdAndFetchState(countryID);
}else{
state = null;
}
return state;
}
@RequestMapping(value = "/cities-json", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public List<City> getCityInJSON(@RequestParam(value="id", required = false) Long countryID,
@RequestParam(value="provinceID", required = false) Long provinceID,
@RequestParam(value="stateID", required = false) Long stateID,
@PageableDefault(sort = "model.model", direction = Sort.Direction.ASC) Pageable pageable,
Model model, HttpServletRequest request, HttpSession session) {
List<City> city;
logger.info("get city,countryID:"+ countryID);
logger.info("get city,provinceID:"+ provinceID);
logger.info("get city,stateID:"+ stateID);
if (provinceID > 0 ) {
city = cityRepository.searchByProvinceIdAndFetchCity(provinceID);
}else{
city = cityRepository.searchByStateIdAndFetchCity(stateID);
}
return city;
}
@RequestMapping(value = "/timezone-json", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public Timezone getTimezoneInJSON(
@RequestParam(value="cityID", required = false) Long cityID,
@PageableDefault(sort = "model.model", direction = Sort.Direction.ASC) Pageable pageable,
Model model, HttpServletRequest request, HttpSession session) {
logger.info("get timezone,cityID:"+ cityID);
if (cityID > 0 ) {
Timezone timezone = timezoneRepository.searchByCityIdAndFetchTimezone(cityID);
logger.info("timezone:"+ timezone.getName());
return timezone;
}else{
return null;
}
}
https://www.iteye.com/blog/gjp014-2387037
Thymeleaf select 使用 和多select 级联选择
https://www.iteye.com/blog/gjp014-2395655
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.w3.org/1999/xhtml" layout:decorator="thymeleaf/templates/layout.html">
<head>
<script type="text/javascript" th:src="@{/js/sgo/endpoint.js}"></script>
<title>Endpoint Form</title>
</head>
<body>
<div layout:fragment="content">
<form action="#" id="endpoint-form" th:object="${endpointForm}" method="post"
th:action="@{/{deviceAction} (deviceAction=${endpointForm.id == null ? 'add-endpoint.mvc' :'endpoints/'+endpointForm.id+'/updateendpoint.mvc'})}" >
<input th:type="hidden" th:field="*{id}" th:if="${endpointForm.id != null}" />
<div th:if="${#fields.hasErrors('*')} or ${resultList != null}" class="alert alert-danger" role="alert">
<ul>
<li th:each="e : ${#fields.detailedErrors()}" th:class="${e.global}? globalerr : fielderr">
<span th:text="${e.global}? '*' : ${e.fieldName}">The field name</span> -
<span th:text="${e.message}">The error message</span>
</li>
<li th:each="r : ${resultList}" th:class="globalerr">
<span th:text="'*'">The field name</span> -
<span th:text="${r.getMessage()}">The error message</span>
</li>
</ul>
</div>
<div th:if="${success != null}" class="alert alert-success" role="alert" th:text="${success}" />
<div class="form-group" th:name="endPointName" th:errorclass="has-error">
<label class="control-label" th:for="endPointName">Endpoint Name <span class="glyphicon glyphicon-asterisk"></span></label>
<input type="text" th:field="*{endPointName}" class="form-control required" id="endPointName"/>
</div>
<div class="row-fluid col-md-12">
<div class="form-group col-md-2" th:name="EPSTypeID" th:errorclass="has-error">
<label class="control-label" th:for="EPSTypeID">Endpoint Type Id <span class="glyphicon glyphicon-asterisk"></span></label>
<select size ="5" th:field="*{EPSTypeID}" class="form-control" id="EPSTypeID">
<option th:each="epsTypes : ${epsTypes}"
th:value="${epsTypes.id}"
th:text="${epsTypes.name}">Endpoint Type Id</option>
</select>
</div>
<div class="form-group col-md-2" th:name="msoId" th:errorclass="has-error" >
<label class="control-label" th:for="msoId">MSO Id <span class="glyphicon glyphicon-asterisk"></span></label>
<select size ="5" th:field="*{msoId}" class="form-control" id="msoID">
<option th:each="mso : ${mso}"
th:value="${mso.id}"
th:text="${mso.name}">MSO Id</option>
</select>
</div>
</div>
<!--div class="row-fluid col-md-12">
<div class="form-group col-md-2" th:name="city" th:errorclass="has-error">
<label class="control-label" th:for="city">City <span class="glyphicon glyphicon-asterisk"></span></label>
<input type="text" th:field="*{city}" class="form-control required" />
</div>
<div class="form-group col-md-2" th:name="state" th:errorclass="has-error" >
<label class="control-label" th:for="state">State </label>
<input type="text" th:field="*{state}" class="form-control required" />
</div>
<div class="form-group col-md-2" th:name="province" th:errorclass="has-error" >
<label class="control-label" th:for="province">Province </label>
<input type="text" th:field="*{province}" class="form-control required" />
</div>
<div class="form-group col-md-2" th:name="country" th:errorclass="has-error" >
<label class="control-label" th:for="country">Country <span class="glyphicon glyphicon-asterisk"></span></label>
<input type="text" th:field="*{country}" class="form-control required" />
</div>
</div-->
<div class="row-fluid col-md-12">
<div class="form-group col-md-2" th:name="country" th:errorclass="has-error" >
<label class="control-label" th:for="country">Country <span class="glyphicon glyphicon-asterisk"></span></label>
<select size ="5" th:field="*{country}" class="form-control" name="startArea1" id="start_select1">
<!--option value="">Choose Country</option-->
<option th:each="country:${country}" th:value="${country.id}" th:text="${country.name}" ></option>
</select>
</div>
<div class="form-group col-md-2" th:name="state" th:errorclass="has-error" >
<label class="control-label" th:for="state">State </label>
<select size ="5" class="form-control" th:field="*{state}" name="startArea3" id="start_select3">
<!--option value="">Choose State</option-->
<option th:each="state : ${state}"
th:value="${state.id}"
th:text="${state.name}">State</option>
</select>
</div>
<div class="form-group col-md-2" th:name="province" th:errorclass="has-error" >
<label class="control-label" th:for="province">Province </label>
<!--select class="form-control" name="startArea2" id="start_select2">
<option value="">Choose Province</option>
</select-->
<select size ="5" class="form-control" th:field="*{province}" id="start_select2">
<option th:each="province : ${province}"
th:value="${province.id}"
th:text="${province.name}">Province</option>
</select>
</div>
<div class="form-group col-md-2" th:name="city" th:errorclass="has-error">
<label class="control-label" th:for="city">City <span class="glyphicon glyphicon-asterisk"></span></label>
<select size ="5" class="form-control" th:field="*{city}" name="startArea4" id="start_select4">
<!--option value="">Choose City</option-->
<option th:each="city : ${city}"
th:value="${city.id}"
th:text="${city.name}">City</option>
</select>
</div>
</div>
<div class="form-group" th:name="timezoneName" th:errorclass="has-error">
<label class="control-label" th:for="TimezoneID">Timezone <span class="glyphicon glyphicon-asterisk"></span></label>
<input type="text" th:field="*{timezoneName}" class="form-control required" id="timezoneName"/>
</div>
<button type="submit" class="btn btn-sm btn-primary" id="endpoint-submit" th:text="${endpointForm.id == null ? 'Create' : 'Update'}">Create</button>
<a th:href="@{{deviceAction} (deviceAction=${endpointForm.id == null ? 'endpoints.mvc' :'/endpoints/'+endpointForm.id+'/devices.mvc'})}" title="Cancel" class="btn btn-sm btn-primary">Cancel</a>
</form>
</div>
</body>
</html>
$(document).ready(function() {
$('#endpoint-form')
.on('change','#start_select1', function() {
//.on('change','#country', function() {
let countryid = $("#start_select1").val();
$.getJSON( "/" + contextRoot + "/provinces-json.mvc?id="+countryid, function( data ) {
let items = [];
$.each( data, function( key, value ) {
console.log(value);
items.push( "<option value='" + value.id + "'>" + value.name + "</option>" );
});
$('#start_select2').html(items.join(""));
});
$.getJSON( "/" + contextRoot + "/states-json.mvc?id="+countryid, function( data ) {
let items = [];
$.each( data, function( key, value ) {
console.log(value);
items.push( "<option value='" + value.id + "'>" + value.name + "</option>" );
});
$('#start_select3').html(items.join(""));
});
$('#start_select4').html("");
document.getElementById("timezoneName").value ="";
})
.on('change','#start_select2', function() {
//.on('change','#province', function() {
let provinceID = $(this).val();
let stateID = 0;
let countryid = $('#start_select1').val();
$.getJSON( "/" + contextRoot + "/cities-json.mvc?id="+countryid+"&provinceID="+provinceID+"&stateID="+stateID, function( data ) {
let items = [];
$.each( data, function( key, value ) {
console.log(value);
items.push( "<option value='" + value.id + "'>" + value.name + "</option>" );
});
$('#start_select4').html(items.join(""));
});
})
.on('change','#start_select3', function() {
//.on('change','#state', function() {
let stateID = $(this).val();
let provinceID = 0;
let countryid = $('#start_select1').val();
$.getJSON( "/" + contextRoot + "/cities-json.mvc?id="+countryid+"&provinceID="+provinceID+"&stateID="+stateID, function( data ) {
let items = [];
$.each( data, function( key, value ) {
console.log(value);
items.push( "<option value='" + value.id + "'>" + value.name + "</option>" );
});
$('#start_select4').html(items.join(""));
});
})
.on('change','#start_select4', function() {
//.on('change','#city', function() {
let cityID = $(this).val();
$.getJSON( "/" + contextRoot + "/timezone-json.mvc?cityID="+cityID, function( data ) {
if(data !=null){
console.log(data.name);
//$('#timezoneName').html(data.name);
document.getElementById("timezoneName").value = data.name;
}
//let items = [];
//$.each( data, function( key, value ) {
//console.log(value);
//items.push( "<option value='" + value.id + "'>" + value.name + "</option>" );
// });
//$('#timezoneName').html(items.join(""));
});
})
.on("click","#endpoint-submit",function(e) {
e.preventDefault();
confirmAdd(dataToParams($('#endpoint-form').data(),$(this).data()));
});
});
@RequestMapping(value = "/provinces-json", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public List<Province> getProvinceInJSON(@RequestParam(value="id", required = false) Long countryID,
@PageableDefault(sort = "model.model", direction = Sort.Direction.ASC) Pageable pageable,
Model model, HttpServletRequest request, HttpSession session) {
List<Province> province;
logger.info("get province,countryID:"+ countryID);
if (countryID != null) {
province = provinceRepository.searchByCountryIdAndFetchProvince(countryID);
}else{
province = null;
}
return province;
}
@RequestMapping(value = "/states-json", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public List<State> getStateInJSON(@RequestParam(value="id", required = false) Long countryID,
@PageableDefault(sort = "model.model", direction = Sort.Direction.ASC) Pageable pageable,
Model model, HttpServletRequest request, HttpSession session) {
List<State> state;
logger.info("get state,countryID:"+ countryID);
if (countryID != null) {
state = stateRepository.searchByCountryIdAndFetchState(countryID);
}else{
state = null;
}
return state;
}
@RequestMapping(value = "/cities-json", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public List<City> getCityInJSON(@RequestParam(value="id", required = false) Long countryID,
@RequestParam(value="provinceID", required = false) Long provinceID,
@RequestParam(value="stateID", required = false) Long stateID,
@PageableDefault(sort = "model.model", direction = Sort.Direction.ASC) Pageable pageable,
Model model, HttpServletRequest request, HttpSession session) {
List<City> city;
logger.info("get city,countryID:"+ countryID);
logger.info("get city,provinceID:"+ provinceID);
logger.info("get city,stateID:"+ stateID);
if (provinceID > 0 ) {
city = cityRepository.searchByProvinceIdAndFetchCity(provinceID);
}else{
city = cityRepository.searchByStateIdAndFetchCity(stateID);
}
return city;
}
@RequestMapping(value = "/timezone-json", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public Timezone getTimezoneInJSON(
@RequestParam(value="cityID", required = false) Long cityID,
@PageableDefault(sort = "model.model", direction = Sort.Direction.ASC) Pageable pageable,
Model model, HttpServletRequest request, HttpSession session) {
logger.info("get timezone,cityID:"+ cityID);
if (cityID > 0 ) {
Timezone timezone = timezoneRepository.searchByCityIdAndFetchTimezone(cityID);
logger.info("timezone:"+ timezone.getName());
return timezone;
}else{
return null;
}
}
评论