1、swagger 不能识别斜杠问题
- Swagger Error
- Resolver error at paths./api/xxx/xxx.post.parameters.0.schema.$ref
- Could not resolve reference because of: Could not resolve pointer: /definitions/PageCondition«xxx» does not exist in document
- 原因
@ApiModel("xxx/xxx列表查询条件")
- 在API注释中出现斜杆
/
,Swagger 无法识别斜杆。
- 解决方案
- 去掉斜杆改为
@ApiModel("xxx、xxx列表查询条件")
- 去掉斜杆改为
2、MyBatis if 标签判断字符串相等
- 问题
<if test="sex=='Y'"> and 1=1 </if>
无法进入 if 标签
- 原因
- 因为 MyBatis 使用 OGNL 表达式进行解析,会把 ‘Y’ 解析为字符
- 在单引号内只有一个字符的情况下,OGNL会将其以 Java 中的 char 类型进行解析,那么此时 char 类型与参数 String 类型用等号进行比较,结果一定 false。
- 解决方案
<if test="sex=='Y'.toString()">
<if test = 'sex== "Y"'>