这里说的是获取浏览器请求过来的参数的意思
总代码参考上一篇(有改动):
https://blog.csdn.net/GLOAL_COOK/article/details/112801651
QuickController :
package cn.itcast.controller;
import cn.itcast.domain.User;
import cn.itcast.domain.VO;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author QLBF
* @version 1.0
* @date 2021/1/17 21:10
*/
@Controller
@RequestMapping("/user") //一级访问目录
public class QuickController {
//下面演示获取请求数据--之获得基本类型参数
@RequestMapping(value = "/quick11",produces = "application/json;charset=utf-8")
@ResponseBody
public void save11(String username,int age) throws Exception {
System.out.println(username);
System.out.println(age);
}
//下面演示获取请求数据--之获得POJO类型参数
@RequestMapping(value = "/quick12",produces = "application/json;charset=utf-8")
@ResponseBody
public void save12(User user) throws Exception {
System.out.println(user);
}
//下面演示获取请求数据--之数组
@RequestMapping(value = "/quick13",produces = "application/json;charset=utf-8")
@ResponseBody
public void save13(String[] strs) throws Exception {
System.out.println(Arrays.asList(strs));
}
//下面演示获取请求数据--之集合有对象,用表单提交
@RequestMapping(value = "/quick14",produces = "application/json;charset=utf-8")
@ResponseBody
public void save14(VO vo) throws Exception {
System.out.println(vo);
}
//下面演示获取请求数据--之集合有对象,用ajax提交
@RequestMapping(value = "/quick15",produces = "application/json;charset=utf-8")
@ResponseBody
public void save15(@RequestBody List<User> userList) throws Exception {
System.out.println(userList);
}
//下面演示获取请求数据--请求参数可以和形参不一样
@RequestMapping(value = "/quick16",produces = "application/json;charset=utf-8")
@ResponseBody
public void save16(@RequestParam(value = "name11",required = false,defaultValue = "李云龙")String username) throws Exception {
System.out.println(username);
}
//下面演示获取请求数据--restful
// localhost:8080/user/quick17/zhangsan17
@RequestMapping(value = "/quick17/{name}",produces = "application/json;charset=utf-8")
@ResponseBody
public void save17(@PathVariable(value = "na