简介
记录漫画上需要被记录学习的东西和错误!
后端
1.JS跨域:
服务器设置允许跨域头,才可以AJAX请求
response.addHeader("Access-Control-Allow-Origin","*"); response.addHeader("Access-Control-Allow-Headers","Content-Type"); response.addHeader("Access-Control-Allow-Methods","GET,POST,PUT,DELETE,OPTIONS");
2. 数据回显乱码
除了数据库到controller层可能会乱码外,服务器到客户端可能也会乱码。
服务器:jdbc:mysql://127.0.0.1:3306/test?characterEncoding=UTF-8 回显数据的响应头:@RequestMethods(values="/xxx", product="application/json;charset=utf-8")
3. IDEA中让Tomcat里资源同运行:
勾选:Deploy applications config in Tomcat instance
4. jackson
ObjectMapper mapper = new ObjectMapper(); Person person = new Person(); person.setName("Tom"); person.setAge(40); String jsonString = mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(person); Person deserializedPerson = mapper.readValue(jsonString, Person.class);
前台
1. async和await:
没有加asyn的函数内,代码就绝对不会同步执行 如下 onLoad() { this.getData(); }
2.