http请求-json-路径参数-服务端接收
This commit is contained in:
@@ -2,9 +2,7 @@ package com.inmind.controller;
|
||||
|
||||
import com.inmind.pojo.User;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -83,4 +81,19 @@ public class RequestController {
|
||||
System.out.println(updateTime.getDayOfMonth());
|
||||
return "ok";
|
||||
}
|
||||
|
||||
|
||||
//接收json请求数据
|
||||
@RequestMapping("/jsonParam")
|
||||
public String jsonParam(@RequestBody User user){
|
||||
System.out.println(user);
|
||||
return "OK";
|
||||
}
|
||||
|
||||
//路径参数(REST风格)
|
||||
@RequestMapping("/path/{id}/{name}")
|
||||
public String pathParam(@PathVariable Integer id,@PathVariable String name) {
|
||||
System.out.println("id:"+id+"name:"+name);
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user