天天看点

mybatis的 xml中传入常量

常量类

public class ConstantUtil {
    public  static  final  String IS_NOT_DEL = "001";
    /**
     * 删除状态
     */
    public enum DelStatus {
        //未删除
        NO_DEL("001"),
        //已删除
        IS_DEL("002");
        private String value;
        private DelStatus(String value) {
            this.value = value;
        }
        public String getValue() {
            return value;
        }
    }
}      

java类中的引用

mybatis的xml中的引用

  • 引用属性

    ​AND del_code = ${@com.platform.utils.ConstantUtil@IS_NOT_DEL}​

  • 引用子类的方法

    ​AND del_code = ${@com.platform.utils.ConstantUtil$DelStatus@NO_DEL.getValue()}​