0516
1.int转string补0:
例:000003
String.format("%06d",12);//其中0表示补零而不是补空格,6表示6位,d表示正数
2.No converter found for return value of type
controller返回值类型没有写get/set方法
3.mybatis
where标签会过滤第一个and
4.null对象可以转换为任何类型
0517
1.返回前端实体不为null的属性
@JsonInclude 作用于实体类
JsonInclude.include.notnull
2.返回前端实体指定格式日期
@JsonFormat (pattern="",timezone="GMT+8")作用于属性
3.限制前端传输的日期格式
@DateTimeFormat
4.连表查询
先连表,再条件查询
???怎么先条件查询,再连表呢
这样需要条件查询的结果集,再连表查询
连表查询逻辑:
根据驱动表的筛选条件过滤的记录,逐条的和被驱动表做关联,将关联的记录放到缓存表中
https://blog.csdn.net/fsdfkjai/article/details/121770629
5.分页查询
当页码大于总页数时,页码总为总页数
原因:reasonable设置为true即分页合理化:当页码大于总页数时,将页码置为总页数
6.tomcat 启动
①查看是否关闭
ps -ef
UID(用户id) PID(进程id) PPID(父进程id) C(cpu占用百分比) STIME(进程开始时间) TTY TIME CMD(开启该进程的命令)
https://blog.51cto.com/svenman/1359919
cmd :没有java 命令时,表示关闭成功
②启动
./startup.sh
ps -ef | grep tomcat
查看到有java命令时,启动成功
③关闭
./shutdown.sh
或
kill -9 pid
需要关闭所有的进程
7.mabatis 模糊查询
like concat('%',#{},'%')
8.SpringMVC⽅法接收参数可以为空、默认值设置
@RequestParam(requried=,defaultValue=)
9.java 返回时间有时间差
@JsonFormat(timezone="GMT+8")
0518
1.一个controller中的方法,只有一个参数可以使用
@RequestBody注解修饰的实体类
会注入http body中的值
2.mybatis
问题:
①判断Integer类型数据是否相等
如下:
<if test=" type == 1"></if>
<if test=" type == 0"></if>
②sql查询type字段一直为1
条件判断一直不生效
原因:条件判断是 使用test = 'type = 1' 使得 type一直为1
③<if test=''> 不生效
mybatis仅传入一个String类型的参数时:
test直接使用参数名,报错
There is no getter for property named 'form' in 'class java.lang.String'
解决办法:
①使用@Param 指定参数名
②使用_parameter
3.post 请求
参数都放到body中,后端才能接收到
!!!4.idea控制台不输出报错信息
捕获了异常,没有输出报错信息
0519
1.模糊查询:特殊字符处理
转义字符:
concat(‘%’,replace(#{},‘%’,‘/%’),‘%’)
2.mybatis sql语句 去空格比较相等
trim(replace(字段,’ ‘,’‘)) = trim(replace(#{},’ ‘,’'))