日志-2021-8-27
RtZhao

数据交换

不想处理非json数据了,收发都是json算了,也好处理

刷新

(1)子页面请求成功后刷新父页面

1
2
3
4
5
6
7
8
9
10
$.ajax({
url:"http://localhost:9091/test/updateUser?"+param,
data:{
},
type:"POST",
success:function (data) {
console.log(data);
parent.location.reload();
}
})

(2)刷新当前表格

1
2
3
4
5
table.reload('currentTableId', {
page: {curr: 1}
}
);
// location.reload(); 或者这样

检索

渲染table.render的异步接口,table.reload where设置额外参数

动态sql

1
2
3
4
5
6
7
8
9
10
11
<where>
<if test="username !=null and username != ''">
and username like concat('%',#{username},'%')
</if>
<if test="gender !=null and gender != ''">
and gender like concat('%',#{gender},'%')
</if>
<if test="startDate != null and endDate != null and startDate != '' and endDate != ''">
and induction_time between #{startDate} and #{endDate}
</if>
</where>

报错

springboot 控制台报错JSON parse error: Unrecognized token ‘*‘: was expecting (‘true‘, ‘false‘ or ‘null‘)

前端返回数据格式不规范。
当dataType指定为json后,1.4+以上的jquery版本对json格式要求更加严格
如果不是严格的json格式,就不能正常执行success回调函数.

JSON格式: 
1)键名称:用双引号 括起   
2)字符串:用使用双引号 括起
3)数字,布尔类型不需要 使用双引号 括起

用JSON.stringify() 方法用于将 JavaScript 值转换为 JSON 字符串

传递多组数据时,后台可用Map键获取值后转换为LinkedHashMap,再用key获取值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const parData={
jsonDataPro:{
k1: "hello",
"k2":"World",
'k3':"SpringBoot",
'k4':'MyBatis',
'k5':123,
},
myData:{
l1:"jquery1.4+",
l2:"大傻逼"
}
}

$.ajax({
url: "http://localhost:9091/test/jsonTran",
contentType: 'application/json;charset=UTF-8',
data: JSON.stringify(parData),
type: "POST",
dataType: "json",
success: function (data) {
console.log(data);
}
})
1
2
3
4
5
6
7
8
9
10
11
@RequestMapping(value = "/jsonTran")
@ResponseBody
public String userDetail(@RequestBody Map<String, Object> map) {
System.out.println(map);
System.out.println(map.get("jsonDataPro"));
LinkedHashMap linkedHashMap= (LinkedHashMap) map.get("jsonDataPro");
System.out.println(linkedHashMap);
System.out.println(linkedHashMap.get("k1"));

return "Hello World";
}
警告 Raw use of parameterized class ‘LinkedHashMap’

不建议使用原生态类型,使用原生态类型会丢失泛型在安全性和表述性方面掉的所有优势。

标签

My favorite color is blue red!

Layui

form

lay-verify

  • required(必填项)
  • phone
  • email
  • url
  • number(数字)
  • data
  • identify(身份证)
  • 自定义值

Layuimini

404页面:设置个计时器,超过时间则显示对应数字
下拉选项:
三级联动下拉选择器:
文件上传:

智慧食堂

智慧食堂

同鑫科技 eHR管理平台

智慧企业

满客宝

博慧通

image-20210827174351415

  • 本文标题:日志-2021-8-27
  • 本文作者:RtZhao
  • 创建时间:2021-08-27 08:41:09
  • 本文链接:https://www.rtzhao.site/2021/08/27/日志-2021-8-27/
  • 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
 评论