xml
resultType
MyBatis查询结果resultType返回值类型详细介绍_留兰香丶的博客-CSDN博客
Mapper
Service
List<Map<String,String>>遍历方法
List<Map<String, String>>遍历的方法_list<map<string,string>>_Spring的思念的博客-CSDN博客
public class Test {
public static void main(String[] args) {
List<Map<String, String>> listMaps = new ArrayList<Map<String, String>>();
Map<String, String> map1 = new HashMap<String, String>();
map1.put("aaa", "111");
map1.put("bbb", "222");
map1.put("ccc", "333");
listMaps.add(map1);
Map<String, String> map2 = new HashMap<String, String>();
map2.put("11", "aa");
map2.put("22", "bb");
map2.put("33", "cc");
listMaps.add(map2);
//方式1:
for (Map<String, String> map : listMaps ) {
for (String s : map.keySet()) {
System.out.print(map.get(s) + " ");
}
}
System.out.println();
System.out.println("-----------------------------");
//方式2:
for (int i = 0; i < listMaps.size(); i++) {
Map<String, String> map = listMaps.get(i);
Iterator iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String string = (String) iterator.next();
System.out.println(map.get(string));
}
}
System.out.println("-----------------------------");
//方式3:
for (Map<String, String> map : listMaps) {
for (Map.Entry<String, String> m : map.entrySet()) {
System.out.print(m.getKey() + " ");
System.out.println(m.getValue());
}
}
System.out.println("-----------------------------");
}
}
Controller
基本数据类型相互转化
Double与String
Double doubleString = Double.parseDouble(toBeDouble);
String stringDouble = toBeString.toString();
使用Java方法实现 Double和String相互转化_double转string_远 F的博客-CSDN博客
接口测试中请求示例如何显示
@RequestBody注解后面不要写JISON,写实体类 地址映射是@PostMapping(value={""},name="")
@RequestParam注解后面写具体的变量,地址映射是@GetMapping(value={""},name="")
model
entity
序列化uid自动生成
光标放到实体类名的后面,然后Alt+Enter。序列化serialVersionUID的值唯一
private static final long serialVersionUID = 526738698185840178L;
vo
返回多个实体类中的数据可以用vo包起来传递
VO.java
import lombok.Data;
import java.io.Serializable;
@Data
public class VO implements Serializable {
//共性
private A a;
//特性
private B b;
dto
分页查询的参数传递可以用dto继承PageDto包起来
controller.java
import com.baomidou.mybatisplus.core.metadata.IPage;
public ResultBody<IPage<VO>> A(@RequestBody Dto dto) {
Page page1 =new Page(dto.getCurrent(), dto.getSize());
IPage<VO> page = baseService.query(page1, dto.getA(), dto.getB());
return ResultBody.succeed(page);
}
Dto.java
@Data
public class Dto extends PageDto {
@ApiModelProperty(value = "A")
private String a;
@ApiModelProperty(value = "B")
private String b;
}