0%

文章字数:100,阅读全文大约需要1分钟

已拦截跨源请求:同源策略禁止读取位于 http://101.132.138.141:8888/service/pageUsers 的远程资源。(原因:CORS 头缺少 ‘Access-Control-Allow-Origin’)。

axios跨域带上cookie,axios session消失

vue的main.js 加上axios.defaults.withCredentials = true;

解决方法

withCredentials的情况下,后端要设置Access-Control-Allow-Origin为你的源地址,例如http://localhost:8080,不能是*,而且还要设置header(‘Access-Control-Allow-Credentials: true’);


文章字数:151,阅读全文大约需要1分钟

vue中使用axios进行一步http访问

引入

1
npm install axios

main.js中

1
2
3
4
import axios from 'axios'
import VueAxios from 'vue-axios'

Vue.use(VueAxios,axios);

使用

1
2
3
4
5
6
7
getMess(){
this.axios.get('api/getNewsList').then((response)=>{
this.newsList=response.data.data;
}).catch((response)=>{
console.log(response);
})
}

GET

1
2
3
4
5
6
7
8
9
10
11
this.axios.get('/user', {//url
params: {//数据
id: 123
}
})
.then(function (response) {
console.log(response);//成功结果
})
.catch(function (error) {
console.log(error);//失败信息
});

#POST

1
2
3
4
5
6
7
8
9
10
this.axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});

并发请求

1
2
3
4
5
6
7
8
9
10
11
12
function getUserAccount() {
return axios.get('/user/12345');
}

function getUserPermissions() {
return axios.get('/user/12345/permissions');
}

this.axios.all([getUserAccount(), getUserPermissions()])
.then(axios.spread(function (acct, perms) {
//两个请求现已完成
}));

this指向

原本vue里this指向vue,但是axios里不是,所以会导致this内容报空。可以在method调用axios的函数开头加上let that=this,然后使用that代替this。


文章字数:18,阅读全文大约需要1分钟

1
2
# 将 D:/server.bat 注册为自启 服务名为tomcat_8080
sc create tomcat_8080 binPath= D:/server.bat start= auto

文章字数:79,阅读全文大约需要1分钟

基本使用

  1. 选择网卡

  2. 1
    2
    3
    4
    5
    1. Capture -> Option
    2. 选择网卡,勾选Prom栏
    3. 勾选 Enable promiscuous mode on all interfaces
    4. 配置抓包过滤器,无则不选择 Capture all in promiscuous mode
    4. 点击start
  3. 数据过滤

  • 选择指定ip(源ip或目标ip)和协议
    1
    ip.addr == 192.168.1.1 and http

文章字数:48,阅读全文大约需要1分钟

之前可以使用的界面突然报错:enabledis not a function at HTMLInputElement.onchange

我的错误是name和方法名相同,冲突了。
id和方法名也可能冲突。

1
<input type="checkbox" name="enable" onchange="enabled(this.checked)">

修改

1
<input type="checkbox" name="yyy" onchange="enabledChange(this.checked)">

文章字数:81,阅读全文大约需要1分钟

设置scriptstyleSheet通过MIME类型过滤不安全的文件

当服务器响应头X-Content-Type-Options: nosniffscriptstyleSheet元素会过滤非指定的MIME文件

stylesheet

stylesheet标签只会加载以下MIME类型的文件

  • text/css

script

script标签只会加载以下MIME类型的文件

  • application/ecmascript
  • application/javascript
  • application/x-javascript
  • text/ecmascript
  • text/javascript
  • text/jscript
  • text/x-javascript
  • text/vbs
  • text/vbscript

文章字数:192,阅读全文大约需要1分钟

一、基本算法

  • 标记-清除算法
  • 复制算法
  • 标记-整理算法
  • 火车算法,没人用了?

二、垃圾收集器组合及适用范围

适用范围及组合

  • 收集器直接有连线,表示可以搭配适用
  • Serial Old作为CMS出现Concurrent Mode Failure失败的后备预案

三、并行收集器和并发收集器

  • 并行Parallel
    多条垃圾收集器线程并行工作,但是用户线程仍然是等待状态。
    ParNewParallel ScavengeParallel Old

  • 并发Concurrent
    用户线程与垃圾收集器线程同时执行
    CMS、G1(也有并行)


文章字数:156,阅读全文大约需要1分钟

今天看《阿里巴巴java开发手册》时看到了一个有意思的空指针异常

1
2
3
4
5
6
Integer a = 1;
Integer b = 2;
Integer c = null;
Boolean flag = false;
// a*b 的结果是 int 类型,那么 c 会强制拆箱成 int 类型,抛出 NPE 异常
Integer result=(flag? a*b : c);

在三元运算符中 条件 ? 表达式1 : 表达式2
如果表达式1和表达式2存在类型对齐,那么可能因此造成空指针异常。
如上面的代码,表达式1的结果是int类型,然后表达式2的结果也对齐拆箱成int,然而变量c的值是空,于是抛出NPE


文章字数:134,阅读全文大约需要1分钟

第一范式1NF

  • 数据库每一列都是不可分割的原子数据

例如:

家庭信息 姓名
上海,3口人 小凯

家庭信息可以拆分成人口住址

第二范式2NF

  • 数据库没一列都应该合主键相关,联合主键中要注意不能只和一个主键相关。

第三范式3NF

  • 非主属性不能依赖其他非主属性,即所有的普通数据只能和主键关联。

文章字数:79,阅读全文大约需要1分钟

主定理最早出现在《算法导论》中,提供了分治方法带来的递归表达式的渐进复杂度分析。规模为n的问题通过分治,得到a个规模为n/b的问题,每次递归带来的额外计算为c(n^d)

计算

T(n) <= aT(n/b) + c(n^d)

  • T(n) = O(n^d log(n)) , if a = b^d
  • T(n) = O(n^d) , if a < b^d
  • T(n) = O(n^logb(a)) , if a > b^d