BS架构,Browser/Server,浏览器/服务器架构模式,客户端只需要浏览器,应用程序的逻辑和数据都存储在服务端。维护方便,体验一般。
CS架构,Client/Server,客户端/服务器架构模式,需要下载单独客户端。开发,维护麻烦,体验不错(数据在客户端,处理快)。
Postman:用于接口测试。
SpringBoot方式获取数据:
@RestController
public class HelloContrller {
//springboot方式
@RequestMapping("/hello")
public String hello(String name,String age){
System.out.println(name+""+age);
return "ok";
}
}
如果Postman发送的参数名不对,需要使用映射
@RequestMapping("/hello")
public String hello(@RequestParam(name = "name") String username, String age){
System.out.println(username+""+age);
return "ok2";
}
}
"name"是实际的参数名,需要根据实际进行更改。
@RequestParam默认需要参数,如果是可选的,需要将这个required改为false
@RequestParam(name = "name",required = false
简单参数:请求参数名和形参对象属性名相同
数组集合参数:针对有多选的
@RequestMapping("/arrayPojo")
public String complePojo(String[]hobby){
System.out.println(Arrays.toString(hobby));
return "ok3";
}
List集合
@RequestMapping("/listPojo")
public String complePojo(@RequestParam List<String>hobby){
System.out.println(hobby);
return "ok4";
}