0%
JS 获取内网 IP 地址(兼容谷歌浏览器)
获取内网 IP 地址
function getIpAddress() {
window.RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
var pc = new RTCPeerConnection({
iceServers: []
}),
noop = function() {};
pc.createDataChannel(''); //create a bogus data channel
pc.createOffer(pc.setLocalDescription.bind(pc), noop); // create offer andsetlocaldescription
pc.onicecandidate = function(ice) {
if (ice && ice.candidate && ice.candidate.candidate) {
var myIP = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/.exec(ice.candidate.candidate)[1];
console.log('my IP: ', myIP); //【注:Chrome浏览器下ice.candidate.address也可以拿到值,火狐浏览器不可以】
pc.onicecandidate = noop;
return myIP;
}
};
return null;
}
SpringBoot 解决 Web 跨域访问的方法汇总
跨域访问时很多需求,所以 SpringBoot 的跨域解决也是必须的。
Access to XMLHttpRequest at 'http://127.0.0.1:18888/XXXX' from origin 'http://127.0.0.1:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Java 不区分大小写的高亮替换
近期在做一个搜索引擎,需要匹配字符高亮显示。
现在有字符串 "struts StrUts hibernate",我想把 不区分大小写匹配 struts 的字符串替换为 <font color='red'>匹配字符串</font>
。
k8s 删除 pod 一直处于 terminating 状态
若 k8s 删除 pod 一直处于 terminating 状态
可强制删除:
kubectl delete pod PODNAME --force --grace-period=0
ElasticSearch Spring-Data Date format always is long
当使用 spring-data 插入日期类型的 Elasticsearch 文档时,我无法获得正确的日期格式,日期格式始终为 Long。