搜索词>>select 耗时0.0130
  • jQuery select 获取值/设置选中

    ​jQuery select 获取值$title(方法一:) let val=$('#selectId').val(); //获取选中值 $title(方法二:) let val=$('#selectId')find('option[sel​jQuery select 获取值$title(方法一:) let val=$('#selectId').val(); //获取选中值 $title(方法二:) let val=$('#selectId')find('option[selected='selected']').attr('value'); //获取选中值  jQuery select 设置默认选中$title(方法一:) $('#selectId').val('your value');  $title(方法二:) $('#selectId').find('option[value='+your value+']').attr('selected','selected');  jQuery触发 select change事件$('#selectId').trigger('change');  
  • bootstrap-select ajax动态添加值中遇到的IE兼容问题解决

    bootstrap-select ajax动态添加值中遇到的IE兼容问题解决bootstrap-select ajax动态添加值中遇到的IE兼容问题解决<br /> <br /> 1.不兼容IE浏览器的方式 <pre> <code class="language-javascript">$(function{ $.ajax({ url:'your request url', type:'GET', success:function(data){ //通过data组装options var options=''; $.each(data.arr,function(index,element){ options+='<option value="'+element.id+'">'+element.value+'</option>'; }) $('#you-select-id').append(options); $('#you-select-id').selectpicker({ style: 'btn-default', noneSelectedText:'请选择', liveSearch:true, size:6,//下拉时候超过6个设置滚动条,默认显示所有 }); $('#you-select-id').selectpicker('refresh'); } }); })</code></pre> <br /> 2.兼容IE浏览器的方式 <pre> <code class="language-javascript">$(function{ $('#you-select-id').selectpicker({ style: 'btn-default', noneSelectedText:'请选择', liveSearch:true, size:6,//下拉时候超过6个设置滚动条,默认显示所有 }); $.ajax({ url:'your request url', type:'GET', success:function(data){ //通过data组装options var options=''; $.each(data.arr,function(index,element){ options+='<option value="'+element.id+'">'+element.value+'</option>'; }) $('#you-select-id').append(options); $('#you-select-id').selectpicker('refresh'); } }); })</code></pre>  
  • @Select注解中动态sql处理mybaties

    在Java编程中,ORM框架mybaties处理@Select注解中的动态sql处理方法在Java编程中,ORM框架mybaties处理@Select注解中的动态sql处理方法<br /> <br /> 代码如下 <pre> <code class="language-java">public interface UserMapper { @Select("<script>select * from user u where u.id in <foreach collection=\"ids\" item=\"item\" index=\"index\" open=\"(\" close=\")\" separator=\",\"> #{item}</foreach> </script>") @Results(value = { @Result(property = "userSex", column = "user_sex", javaType = String.class), @Result(property = "userName", column = "user_name"), @Result(property = "userAge", column = "user_age") }) List<User> list(@Param("ids")Long [] ids); }</code></pre> <br /> <strong>简单的说就是讲以前mapper.XML中的sql写法搬到Java代码中.用<SCRIPT></SCRIPT>包裹起来</strong>
  • MySQL查询结果添加序号

    MySQL查询结果添加序号常规查询结果如下:SQL命令:SELECT * FROM test;​现在我们需要添加一行序列号,也就是1,2,3,4...那种MySQL查询结果添加序号常规查询结果如下:SQL命令:SELECT * FROM test;​现在我们需要添加一行序列号,也就是1,2,3,4...那种。SQL命令如下:SELECT (@sn :=@sn + 1) sn,a.* from test a,(select @sn :=0) b;执行结果如下:​搞定收工。如果需要倒序则再进行一次子查询根据SN排序即可。
  • Bootstrap Table 多选以及获取多选值

    ​Bootstrap TableBootstrap Table 多选以及获取多选值实现本文主要讲解在bootstrap table组建使用过程中,配置多选和获取多选选中的值​Bootstrap TableBootstrap Table 多选以及获取多选值实现本文主要讲解在bootstrap table组建使用过程中,配置多选和获取多选选中的值。首先是配置Bootstrap Table 多选$('#tableId').bootstrapTable({ //****省略其他配置****** singleSelect:false,//是否单选,false表示多选;true标识只能单选 clickToSelect: true,//启用点击某行就选中某行 columns:[ {field: 'chk', checkbox: true},//注意这里的field尽量不用返回数据的字段名,否则后面获取选中值的时候会把该字段的值变为true或者false //*****其他字段省略**** ] })获取Bootstrap Table 多选选中值var selected = $('#tableId').bootstrapTable('getSelections'); //返回值为数据对象数组 if(selected&&selected.length>0){ //非空数组时候进行的操作 $.each(selected,function(index,item){ console.log(item); }) }else{ //空数组的操作 }Bootstrap Table 图像 小部件
  • Vue.js底部导航三种写法

    普通写法​vantUI 使用字体图标和文字<template>l; <van-tabbar v-model="active" active-color="#07c160">l; <van-tabbar-item :to="{普通写法​vantUI 使用字体图标和文字<template> <van-tabbar v-model="active" active-color="#07c160"> <van-tabbar-item :to="{name:'home'}"> <span>首页</span> <img slot="icon" slot-scope="props" :src="props.active ? icon.homeActive : icon.homeNormal" > </van-tabbar-item> <van-tabbar-item :to="{name:'money'}"> <span>钱包</span> <img slot="icon" slot-scope="props" :src="props.active ? icon.moneyActive : icon.moneyNormal" > </van-tabbar-item> <van-tabbar-item :to="{name:'user'}"> <span>个人中心</span> <img slot="icon" slot-scope="props" :src="props.active ? icon.userActive : icon.userNormal" > </van-tabbar-item> </van-tabbar> </template> <script> export default { data() { return { active: 0, icon:{ homeNormal: require('./home.png'), homeActive: require('./homeActive.png'), moneyNormal: require('./money.png'), moneyActive: require('./moneyActive.png'), userNormal: require('./user.png'), userActive: require('./userActive.png'), }, } } } </script>手写 适用于背景图等复杂样式<template> <div class="footer"> <div class="foot"> <router-link v-for="(item,i) in footnavs" :key="i" :to="item.to" :class="{'selected':($route.meta.nav_index==item.nav_index)}" > <img :src="$route.meta.nav_index==item.nav_index?item.selected:item.no_selected" alt> <span v-show="!($route.meta.nav_index==item.nav_index)">{{item.name}}</span> </router-link> </div> </div> </template> <script> export default { data() { return { footnavs: [ { to: "/", name: "首页", no_selected: require("@img/home/shouye@2x.png"), selected: require("@img/home/shouye2@2x.png"), nav_index: 1 }, { to: "/money", name: "钱包", no_selected: require("@img/home/qianbao@2x.png"), selected: require("@img/home/qianbao2@2x.png"), nav_index: 2 }, { to: "/my", name: "个人中心", no_selected: require("@img/home/gerenhzongxin@2x.png"), selected: require("@img/home/gerenzhongxin@2x.png"), nav_index: 3 } ] }; } }; </script> <style lang="less" scoped> .footer { width: 100%; height: 98px; margin-top: 12px; .foot { width: 100%; position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 10px 20px; background: rgba(255, 255, 255, 1); box-shadow: 0px 1px 16px 0px rgba(192, 192, 192, 0.4); a { width: 33%; text-align: center; display: flex; flex-direction: column; justify-content: space-around; align-items: center; img { width: 47px; height: 47px; } span { font-size: 28px; color: rgba(102, 102, 102, 1); } &.selected { img { width: 85px; height: 85px; } } } } } </style>路由文件import Vue from 'vue' import Router from 'vue-router' import home from '@/pages/home/home' import noticeList from '@/pages/home/noticeList' import money from '@/pages/money/money' import my from '@/pages/my/my' Vue.use(Router) export default new Router({ routes: [{ path: '/', name: 'home', component: home, meta: { index: 0, hasFooter: true, nav_index: 1 }, }, { path: '/money', name: 'money', component: money, meta: { index: 0, hasFooter: true, nav_index: 2 }, }, { path: '/my', name: 'my', component: my, meta: { index: 0, hasFooter: true, nav_index: 3 }, }, { path: '/noticeList', name: 'noticeList', component: noticeList, meta: { index: 1, hasBar: true, }, }, ], //该方法用于控制滚动行为, scrollBehavior(to, form, savedPosition) { if (savedPosition) { return savedPosition } else { return { x: 0, y: 0 } } } })app.vue文件<template> <div id="app"> <tabBar v-show="$route.meta.hasBar"/> <transition :name="transitionName"> <router-view/> </transition> <Footer v-show="$route.meta.hasFooter"/> </div> </template> <script> import "./common/css/common.css"; // bug:不能为小写footer会报错 import Footer from "@/components/footer"; import tabBar from "@/components/tabBar"; export default { name: "App", data() { return { transitionName: "" }; }, components: { Footer, tabBar }, mounted() {}, watch: { /* * 使用watch 监听$router的变化 * 如果to索引大于from索引,判断为前进状态,反之则为后退状态 * 设置动画名称 */ $route(to, from) { if (to.meta.index == from.meta.index) { this.transitionName = ""; } else if (to.meta.index > from.meta.index) { this.transitionName = "slide-left"; } else { this.transitionName = "slide-right"; } } } }; </script>​​​​​​​
  • mysql存储过程基础实例

    mysql存储过程基础实例1.选择一个数据库创建表TEST_USER,并插入一些测试数据 <pre> <code class="language-sql">DROP TABLE IF EXISTS TEST_USER; CREATE TABLE TEST_USER( id int primary key not null, name varchar(255), age int, sex varchar(2) ); insert into TEST_USER (id,name,age,sex) values(1,"测试名称1",8,"男"); insert into TEST_USER (id,name,age,sex) values(2,"测试名称2",14,"男"); insert into TEST_USER (id,name,age,sex) values(3,"测试名称3",13,"男"); insert into TEST_USER (id,name,age,sex) values(4,"测试名称4",28,"男"); insert into TEST_USER (id,name,age,sex) values(5,"测试名称5",13,"男"); insert into TEST_USER (id,name,age,sex) values(6,"测试名称6",8,"男"); insert into TEST_USER (id,name,age,sex) values(7,"测试名称1",28,"男"); </code></pre> 执行结果:<br /> <img alt="执行结果,模拟数据" class="img-thumbnail" src="/assist/images/blog/4a3c2e50-49ff-4355-80db-81a7b423f800.jpg" style="height:204px; width:446px" /><br /> 2.创建一个最基础的存储过程 <pre> <code class="language-sql">CREATE PROCEDURE PBase() BEGIN SELECT * FROM TEST_USER; END</code></pre> 执行结果:<br /> <img alt="基础1" class="img-thumbnail" src="/assist/images/blog/abd128c7-c9b3-4719-b424-c47219324e86.jpg" style="height:267px; width:557px" /><br /> 执行基础的存储过程: <pre> <code class="language-sql">call PBase();</code></pre> <img alt="2" class="img-thumbnail" src="/assist/images/blog/6c093ce3-56cc-4434-bf08-5aa933bea79a.jpg" style="height:390px; width:797px" /><br /> 3.创建一个带输入参数的存储过程 <pre> <code class="language-sql">DROP PROCEDURE IF EXISTS P1; CREATE PROCEDURE P1(IN maxAge INT) BEGIN SELECT * FROM TEST_USER t WHERE t.age>maxAge; END</code></pre> <br /> 调用: <pre> <code class="language-sql">call P1(10);</code></pre> <img alt="执行结果" class="img-thumbnail" src="/assist/images/blog/798df4d0-c655-477f-8447-150fb5633ccd.jpg" style="height:592px; width:878px" /><br /> 4.创建一个带有输出参数的存储过程 <pre> <code class="language-sql">drop PROCEDURE if exists P2; create PROCEDURE P2(out total int) begin select count(id) into total from test_user; end;</code></pre> 调用: <pre> <code class="language-sql">call p2(@out); select @out</code></pre> <img alt="输出" class="img-thumbnail" src="/assist/images/blog/f38f2ff7-6d82-41c3-9d95-a930e15e77ad.jpg" style="height:609px; width:759px" /><br /> 5.创建一个带输入参数又带输出参数的存储过程 <pre> <code class="language-sql">DROP PROCEDURE IF EXISTS P3; CREATE PROCEDURE P3(IN maxAge INT,OUT total INT) BEGIN SELECT count(id) into total FROM TEST_USER t WHERE t.age>maxAge; END </code></pre> 执行:<br /> <img alt="3" class="img-thumbnail" src="/assist/images/blog/30fdf4b9-f85e-41fa-b510-3c62add76530.jpg" style="height:644px; width:916px" /><br /> 6.创建一个即是输入又是输出参数并且喊判断语句的存储过程 <pre> <code class="language-sql">DROP PROCEDURE IF EXISTS P4; CREATE PROCEDURE P4(INOUT param INT) BEGIN IF param = 10 THEN SELECT count(id) into param FROM TEST_USER t; ELSE SELECT count(id) into param FROM TEST_USER t WHERE t.age<param; END IF; END</code></pre> <br /> 执行1:参数10 <pre> <code class="language-sql">set @param=10; call P4(@param); select @param; </code></pre> <br /> <img alt="1111" class="img-thumbnail" src="/assist/images/blog/7b42c24d-0b73-4cff-a713-1b43a1a8975c.jpg" style="height:592px; width:864px" /><br /> 执行:参数9 <pre> <code class="language-sql">set @param=9; call P4(@param); select @param; </code></pre> <img alt="123" class="img-thumbnail" src="/assist/images/blog/6f5122e4-1853-4c75-a80d-7ec302e6baf5.jpg" style="height:584px; width:728px" />
  • bootstrap table插件使用说明demo

    bootstrap table插件使用说明demo该插件是基于bootstrap框架开发的一个table插件,功能强大实用性强<br /> 展示结果截图:<br /> <img alt="bootstrap table插件使用效果图" class="img-thumbnail" src="/assist/images/blog/6a731324-c558-4ca7-8e9a-08affc0a941c.png" style="height:561px; width:1117px" /><br /> 1.下载bootstrap table插件,<a href="https://github.com/wenzhixin/bootstrap-table" rel="nofollow" target="_blank">下载</a><br /> 2.导入插件相关的css和js文件,当然bootstrap框架的基本组件必须导入 <pre> <code class="language-html"><link rel="stylesheet" href="bootstrap3/plugins/bootstrap-table/dist/bootstrap-table.min.css"> <script src="bootstrap3/plugins/bootstrap-table/dist/bootstrap-table.js"></script> <script src="bootstrap3/plugins/bootstrap-table/dist/locale/bootstrap-table-zh-CN.js"></script></code></pre> 3.body中添加一个table,给一个id,添加一个搜索的工具栏 <pre> <code class="language-html"><div class="search_bar form-inline" id="search_bar"> <span>著作:</span> <select class="form-control" id="search_copyright"> <option value="">全部</option> <option value="Original">原创</option> <option value="Reproduced">转载</option> <option value="Translation">翻译</option> </select> <span>状态:</span> <select class="form-control" id="search_status"> <option value="">全部</option> <option value="Normal">已发布</option> <option value="UnAudit">待审核</option> </select> <span>排序:</span> <select class="form-control" id="search_order"> <option value="createTime" title="创建时间排序">创时</option> <option value="updateTime" title="更新时间排序" selected="selected">更时</option> </select> <span>标题:</span> <input type="text" class="form-control" placeholder="输入博客标题" id="serach_title">&nbsp;<button class="btn btn-default" id="search_btn">查询</button>&nbsp; </div> <table id="table"></table></code></pre> 4.写js <pre> <code class="language-javascript">$(function(){     $('#table').bootstrapTable({         url:'manager/blog/list.json',         method:'get',         contentType:'application/json',         showColumns: true, //显示隐藏列           showRefresh: true,  //显示刷新按钮         toolbar:'#search_bar',         queryParams:queryPrams,          pagination: true,           pageSize: 10,          pageList:[10],          sidePagination: "server",         columns: [{             field: 'title',             title: '博客标题'         },{             field: 'authorName',             title: '作者'         },{             field:'copyright',             title:'版权',             formatter:function(value,row,index){                 var cp=value;                 if(value=='Reproduced'){                     cp='转载';                 }else if(value=='Translation'){                     cp='翻译';                 }else if(value=='Original'){                     cp='原创';                 }                 return cp;             },              width:50         },{             field: 'autoAuditDate',             title: '自动审核日期'         },{             field: 'status',             title: '状态',             formatter:function(value,row,index){                 var status=value;                 if(value=='Normal'){                     status='正常';                 }else if(value=='UnAudit'){                     status='待审核';                 }else if(value=='Refuse'){                     status='驳回';                 }else if(value=='AutoAudit'){                     status='自审核';                 }                 return status;             },             width:60         },{             field: 'updateTime',             title: '更新时间',             formatter:function(value,row,index){                 return $.timestamp2string(value,'yyyy-MM-dd hh:mm:ss');             },             width:170         },{             field: 'id',              title:'操作',             formatter:function(value,row,index){                 var p='<a class="btn btn-xs btn-default" title="预览博客" href="manager/blog/view/'+value+'.html" target="_blank">预</a>&nbsp;';                 var a='<button class="btn btn-xs btn-success" title="通过审核" onclick="audit('+value+')">审</button>&nbsp;';                 var auto='<button class="btn btn-xs btn-success" title="定时自动审核" onclick="auditAuto('+value+')">定</button>&nbsp;';                 var r='<button class="btn btn-xs btn-default" title="拒绝审核" onclick="auditCanncel('+value+')">驳</button>&nbsp;';                 return p+a+auto+r;             },             width:130         }]     }) //查询事件绑定     $('#search_btn').click(function(){         $("#table").bootstrapTable('refresh');     });     $('#search_status').change(function(){         $("#table").bootstrapTable('refresh');     });     $('#search_copyright').change(function(){         $("#table").bootstrapTable('refresh');     });     $('#search_order').change(function(){         $("#table").bootstrapTable('refresh');     });</code></pre> <br /> <br />  
  • Java编程之MyBatis框架sql中变量引用方式#{}与${}的区别

    Java编程之MyBatis框架sql中变量引用方式#{}与${}的区别Java编程之MyBatis框架sql中变量引用方式#{}与${}的区别<br /> <br /> #{}和 ${}传参的区别如下:<br /> 1.使用#传入参数是,sql语句解析变量时候将添加""包裹变量,当成字符串来解析,$则不会用""包裹;<br /> 2.#能使用PreparedStatement语句提高一定的效率;<br /> 3.#{}传参能防止sql注入,如果你传入的参数为 单引号',那么如果使用${},这种方式 那么是会报错的;<br /> 4.如果要做动态的排序,动态查询某个字段比如 order by column,这个时候务必要用${},select * from table order by 'name' ,这样是没用<br /> 5.从安全角度出发,能用#就不要用$;<br /> <br /> 总结:<br /> 简单来说#{} 解析的是占位符?可以防止SQL注入, 比如打印出来的语句  <pre> <code class="language-sql">select * from table where id=?</code></pre> <br /> 然而${} 则是不能防止SQL注入打印出来的语句  <pre> <code class="language-sql">select * from table where id=2 </code></pre> <br /> 实实在
  • mybaties mapper 继承机制解决改表改mapper的苦恼

           本文主要讲解在使用mybaties中通过mybaties generator生成基本操作代码,然后通过 mybaties mapper 继承机制来解决某些情况下经常改表导致改mapper文件的苦恼       本文主要讲解在使用mybaties中通过mybaties generator生成基本操作代码,然后通过 mybaties mapper 继承机制来解决某些情况下经常改表导致改mapper文件的苦恼。好了废话少说上代码了首先是 mapper java文件的继承$title(ArticleMapper.java) public interface ArticleMapper { int deleteByPrimaryKey(Integer id); int insert(Article record); int insertSelective(Article record); Article selectByPrimaryKey(Integer id); int updateByPrimaryKeySelective(Article record); int updateByPrimaryKey(Article record); }以上mapper文件为mybaties generator生成的代码。$title(ArticleExtMapper.java) public interface ArticleExtMapper extends ArticleMapper { Article getLast(@Param("id") Integer id, @Param("type") Integer type); Article getNext(@Param("id") Integer id, @Param("type") Integer type); List<Article> getList(@Param("title") String title, @Param("category") String category, @Param("type") Integer type); } 以上为业务使用中扩展的一些应用查询方法下面上mapper xml文件的使用$title(ArticleMapper.xml) <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="net.ifok.ocms.business.mapper.ArticleMapper"> <resultMap id="BaseResultMap" type="net.ifok.ocms.business.model.Article"> <id column="id" jdbcType="INTEGER" property="id" /> <result column="title" jdbcType="VARCHAR" property="title" /> <result column="image" jdbcType="VARCHAR" property="image" /> <result column="url" jdbcType="VARCHAR" property="url" /> <result column="content" jdbcType="VARCHAR" property="content" /> <result column="content_text" jdbcType="VARCHAR" property="contentText" /> <result column="category" jdbcType="VARCHAR" property="category" /> <result column="type" jdbcType="INTEGER" property="type" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="keywords" jdbcType="VARCHAR" property="keywords" /> <result column="description" jdbcType="VARCHAR" property="description" /> <result column="customer" jdbcType="VARCHAR" property="customer" /> </resultMap> <sql id="Base_Column_List"> id, title, image, url, content, content_text, category, type, create_time, update_time, keywords, description, customer </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from article where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> delete from article where id = #{id,jdbcType=INTEGER} </delete> <insert id="insert" parameterType="net.ifok.ocms.business.model.Article"> insert into article (id, title, image, url, content, content_text, category, type, create_time, update_time, keywords, description, customer) values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{image,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{contentText,jdbcType=VARCHAR}, #{category,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{keywords,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{customer,jdbcType=VARCHAR}) </insert> <insert id="insertSelective" parameterType="net.ifok.ocms.business.model.Article"> insert into article <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="title != null"> title, </if> <if test="image != null"> image, </if> <if test="url != null"> url, </if> <if test="content != null"> content, </if> <if test="contentText != null"> content_text, </if> <if test="category != null"> category, </if> <if test="type != null"> type, </if> <if test="createTime != null"> create_time, </if> <if test="updateTime != null"> update_time, </if> <if test="keywords != null"> keywords, </if> <if test="description != null"> description, </if> <if test="customer != null"> customer, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id,jdbcType=INTEGER}, </if> <if test="title != null"> #{title,jdbcType=VARCHAR}, </if> <if test="image != null"> #{image,jdbcType=VARCHAR}, </if> <if test="url != null"> #{url,jdbcType=VARCHAR}, </if> <if test="content != null"> #{content,jdbcType=VARCHAR}, </if> <if test="contentText != null"> #{contentText,jdbcType=VARCHAR}, </if> <if test="category != null"> #{category,jdbcType=VARCHAR}, </if> <if test="type != null"> #{type,jdbcType=INTEGER}, </if> <if test="createTime != null"> #{createTime,jdbcType=TIMESTAMP}, </if> <if test="updateTime != null"> #{updateTime,jdbcType=TIMESTAMP}, </if> <if test="keywords != null"> #{keywords,jdbcType=VARCHAR}, </if> <if test="description != null"> #{description,jdbcType=VARCHAR}, </if> <if test="customer != null"> #{customer,jdbcType=VARCHAR}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="net.ifok.ocms.business.model.Article"> update article <set> <if test="title != null"> title = #{title,jdbcType=VARCHAR}, </if> <if test="image != null"> image = #{image,jdbcType=VARCHAR}, </if> <if test="url != null"> url = #{url,jdbcType=VARCHAR}, </if> <if test="content != null"> content = #{content,jdbcType=VARCHAR}, </if> <if test="contentText != null"> content_text = #{contentText,jdbcType=VARCHAR}, </if> <if test="category != null"> category = #{category,jdbcType=VARCHAR}, </if> <if test="type != null"> type = #{type,jdbcType=INTEGER}, </if> <if test="createTime != null"> create_time = #{createTime,jdbcType=TIMESTAMP}, </if> <if test="updateTime != null"> update_time = #{updateTime,jdbcType=TIMESTAMP}, </if> <if test="keywords != null"> keywords = #{keywords,jdbcType=VARCHAR}, </if> <if test="description != null"> description = #{description,jdbcType=VARCHAR}, </if> <if test="customer != null"> customer = #{customer,jdbcType=VARCHAR}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="net.ifok.ocms.business.model.Article"> update article set title = #{title,jdbcType=VARCHAR}, image = #{image,jdbcType=VARCHAR}, url = #{url,jdbcType=VARCHAR}, content = #{content,jdbcType=VARCHAR}, content_text = #{contentText,jdbcType=VARCHAR}, category = #{category,jdbcType=VARCHAR}, type = #{type,jdbcType=INTEGER}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP}, keywords = #{keywords,jdbcType=VARCHAR}, description = #{description,jdbcType=VARCHAR}, customer = #{customer,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} </update> </mapper> 以上为mybaties generator生成的代码。 $title(ArticleExtMapper.xml) <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="net.ifok.ocms.business.mapper.ext.ArticleExtMapper"> <resultMap id="BaseResultMap" type="net.ifok.ocms.business.model.Article" extends="net.ifok.ocms.business.mapper.ArticleMapper.BaseResultMap"> </resultMap> <select id="getLast" resultMap="BaseResultMap"> select * FROM article where type=${type} and id <![CDATA[ < ]]> #{id} order by id desc limit 1 </select> <select id="getNext" resultMap="BaseResultMap"> select * FROM article where type=#{type} and id <![CDATA[ > ]]>#{id} order by id asc limit 1 </select> <select id="getList" resultMap="BaseResultMap"> SELECT * from article where 1=1 and type=#{type} <if test="title!=null"> and title like CONCAT(CONCAT('%', #{title}), '%') </if> <if test="category !=null and category !=''"> and category=#{category} </if> order by create_time desc </select> </mapper> 以上为扩展查询事项说明:ArticleMapper中有,ArticleExtMapper.xml中没有,ArticleExtMapper沿用ArticleMapper中的定义ArticleMapper中有,ArticleExtMapper.xml中也有,ArticleExtMapper使用ArticleExtMapper.xml中的定义ArticleMapper中没有,ArticleExtMapper.xml中有,ArticleExtMapper使用ArticleExtMapper.xml中的定义  ResultMap覆盖Mapper.xml继承机制只针对statement有效,对于sql、resultMap是无效的。如果要在ArticleExtMapper.xml中覆盖这些,必须要先覆盖ParentMapper.xml中的statement,然后让这些statement使用新的sql、resultMap等。总结通过上面的将扩展的部分分开来写,后续改表,生成部分的代码直接覆盖即可,不担心扩展的不见了,二使用的时候直接使用扩展的mapper即可,扩展的mapper包含所有的方法。over ,Enjoy​​​​​​​