小程序制作模板网站,怎么建立一个属于自己的网站,中国黄金集团j建设公司网站,信用信息公示网官网输入参数#xff1a;parameterType 两种取值符号的异同 1.类型为简单类型(8个基本类型string) 不同点: a.#{任意值}#xff0c;${value} 其中的标识符只能是value b. #{}自动给String类型加上单引号(‘’) (自动类型转换) ${} 原样输出#xff0c;适合于动态排序 #xff0… 输入参数parameterType 两种取值符号的异同 1.类型为简单类型(8个基本类型string) 不同点: a.#{任意值}${value} 其中的标识符只能是value b. #{}自动给String类型加上单引号(‘’) (自动类型转换) ${} 原样输出适合于动态排序 动态字段 c.#{}可以防止sql注入 ${}不防止sql注入 相同点: 都可以获取对象的值或者嵌套对象的值 2.类型为对象类型: #{属性名} ${属性名} 输出参数:ResultType和ResultMap 在属性名和字段名不一致时的解决办法 1.使用ResultMap 1 select idqueryStudentById parameterTypeint resultMapstudent12 select * from student where sid #{sid}3 /select4 resultMap typestudent idstudent15 id propertysid columnsid /6 result propertysname columnsname /7 result propertyage columnage /8 result propertysex columnsex /9 association propertyaddress javaTypeaddress
10 result propertyhomeAddress columnhomeaddress /
11 result propertyschoolAddress columnschooladdress /
12 /association
13 /resultMap 2.使用ResultType HashMap解决: 1 insert idinsertStudentWithHashMap parameterTypeHashMap
2 insert into student (sname,age,sex,homeaddress,schooladdress) value (#{sname},#{age},#{sex},#{homeaddress},#{schooladdress})
3 /insert 1 MapString, Object map new HashMapString, Object();
2 map.put(sname, 馒头);
3 map.put(age, 22);
4 map.put(sex, true);
5 map.put(homeaddress, 杭州);
6 map.put(schooladdress, 北京);
7 studentMapper.insertStudentWithHashMap(map); 1 //实体类 private int sno;
2 private String name;
3 private int age;
4 private Boolean sex;
5 private Address address; 转载于:https://www.cnblogs.com/man-tou/p/11336592.html