1.springboot实现RsetFull风格
在控制器controller包下
使用@PathVariable注解
@RestController
public class RestFullController {
@RequestMapping("/name/{name}")
public Object user(@PathVariable("name") String name){
Student student = new Student();
student.setName("nihao");
student.setAddress("123");
return student;
}
}
在浏览器中用localhost:8080/name/nihao 就能得到对应的json数据
注意:最好不要在两同类型的参数下交换位置 这样会引起歧义
其次是Mapper注解规范
PostMapping:接收和处理Post方式的请求
DeleteMapping:接收delete方式的请求,可以使用GetMapping代替
PutMapping:接收put方式的请求,可以用PostMapping代替
GetMapping;接收get方式的请求
2.springboot实现热部署
<!-- springboot 开发自动热部署 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
改动代码完后 就build上选择 build相应的模块