SpringBoot5-Restful风格CRUD
一、Restful风格CRUD
1.1 就是一种规范
都是emp/1,你发送get就执行查询,发送put就执行修改
以前像springmvc这样配置路径就不需要你做了
1.2 示例代码
1.2.1 查询
限定请求方式为get
转换日期格式
1.2.2 添加
1.2.2.1 添加前跳转查询(部门)
查询跳转,添加之前的准备,超链接为get
1.2.2.2 真正添加
用请求方式来区分
一定注意最后要重定向请求/emps的Controller,会自动跳转至查询页面,如果直接请求emps页面就什么数据都没有
配置日期转换,否则会按照国外的格式,报错
1.2.3 修改
@$两套语法,中间要用+隔开
以前c标签写法,按顺序排列
开启禁用的put和delete请求
1.2.4 删除
跟修改是一样的,要带一个参数过来
这个可以实现,但是每个数据都弄一个表单,网页负担太大,怎么改进?
通过动态绑定action,只写一个form表单就可以了
自定义一个属性delurl,把这个表单的action赋给它
通过js小技巧把这个delurl赋给delform表单的action属性