javaEEday05-请求响应-请求-路径参数
This commit is contained in:
@@ -3,10 +3,7 @@ package com.inmind.controller;
|
||||
import com.inmind.pojo.User;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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 java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
@@ -67,7 +64,7 @@ public class RequestController {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
//日期参数
|
||||
//json参数
|
||||
@RequestMapping( "/jsonParam")
|
||||
//@RequestBody: 将请求体中的json数据,映射为java对象
|
||||
public String jsonParam(@RequestBody User user){
|
||||
@@ -75,4 +72,13 @@ public class RequestController {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
//路径参数
|
||||
@RequestMapping( "/path/{id}/{name}")
|
||||
//@PathVariable: 将路径参数映射为方法参数
|
||||
public String pathParam(@PathVariable Integer id,@PathVariable String name){
|
||||
System.out.println("id:"+id);
|
||||
System.out.println("name:"+name);
|
||||
return "OK";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user