主要參考另外兩篇博文,這裏表示感謝javascript
參考一(mybatisplus3.x分頁) : https://www.jianshu.com/p/2ec9337dc2b0html
參考二(mybatisplus2.x升級3.x) : https://my.oschina.net/u/241218/blog/1838534java
mybatisplus2.x 和 mybatisplus3.x 變化比較大, 資料查詢的時候注意版本, 能夠避依賴衝突.mysql
0.新建springboot web項目(打包模式必定要用war包 ,不然報錯找不到模版,目前還不知道緣由)web
1. demo項目環境 springboot-2.1.1 + mybatisplus3.0.6 + velocity2.0 + jdk1.8 + ideaajax
2. application.ymlspring
server: port: 8080 servlet: context-path: /maven #項目名稱 spring: profiles: active: local #@spring.active@ #默認使用本地配置文件 mvc: static-path-pattern: /static/** view: prefix: /WEB-INF/view devtools: restart: enabled: false additional-paths: src/main/java exclude: static/**,WEB-INF/view/** servlet: multipart: max-request-size: 100MB max-file-size: 100MB freemarker: allow-request-override: false cache: false check-template-location: true charset: utf-8 content-type: text/html expose-request-attributes: false expose-session-attributes: false expose-spring-macro-helpers: true suffix: .ftl settings: auto_import: /spring.ftl as spring template_update_delay: 0 mybatis-plus: mapper-locations: classpath*:/mapper/**Mapper.xml #實體掃描,多個package用逗號或者分號分隔 typeAliasesPackage: com.dofun.code.entity global-config: #主鍵類型 0:"數據庫ID自增", 1:"用戶輸入ID",2:"全局惟一ID (數字類型惟一ID)", 3:"全局惟一ID UUID"; id-type: 0 #字段策略 0:"忽略判斷",1:"非 NULL 判斷"),2:"非空判斷" field-strategy: 2 #駝峯下劃線轉換 db-column-underline: true #刷新mapper 調試神器 refresh-mapper: true #邏輯刪除配置(下面3個配置) logic-delete-value: 0 logic-not-delete-value: 1 configuration: map-underscore-to-camel-case: true cache-enabled: false #logging logging: path: maven-logs level: com.dofun: debug #這個改爲本身項目路徑,否則可能報錯 --- spring: profiles: local datasource: url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&useServerPrepStmts=false&serverTimezone=Hongkong username: root password: root db-name: test filters: wall,mergeStat
3. pom 工程依賴sql
<dependencies> <!--springboot依賴--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- mybatis-plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatisplus-spring-boot-starter</artifactId> <version>1.0.5</version> </dependency>
<!-- 內部集成mybatis和mybatis-spring, 不須要在引入, 避免版本衝突 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>3.0.6</version> </dependency> <!-- druid鏈接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.10</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.11</version> <scope>runtime</scope> </dependency> <!-- 模版引擎 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-engine-core</artifactId> <version>2.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!-- java編譯插件,maven默認1.5版本太低,指定爲1.8 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <!--編譯打包時,忽略測試類--> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build>
4. MpGenerator 代碼生成器數據庫
package com.dofun.config; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.generator.AutoGenerator; import com.baomidou.mybatisplus.generator.InjectionConfig; import com.baomidou.mybatisplus.generator.config.*; import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert; import com.baomidou.mybatisplus.generator.config.po.TableFill; import com.baomidou.mybatisplus.generator.config.po.TableInfo; import com.baomidou.mybatisplus.generator.config.rules.DbColumnType; import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class MpGenerator { /** * <p> * MySQL 生成演示 * </p> */ public static void main(String[] args) { // 自定義須要填充的字段 List<TableFill> tableFillList = new ArrayList<>(); tableFillList.add(new TableFill("ASDD_SS", FieldFill.INSERT_UPDATE)); AutoGenerator mpg = new AutoGenerator(); // 選擇 freemarker 引擎,默認 Veloctiy // mpg.setTemplateEngine(new FreemarkerTemplateEngine()); // 全局配置 GlobalConfig gc = new GlobalConfig(); gc.setOutputDir("F:\\idea-maven\\maven\\src\\main\\java"); gc.setFileOverride(true); gc.setActiveRecord(true);// 不須要ActiveRecord特性的請改成false gc.setEnableCache(false);// XML 二級緩存 gc.setBaseResultMap(true);// XML ResultMap gc.setBaseColumnList(true);// XML columList //gc.setKotlin(true);//是否生成 kotlin 代碼 gc.setAuthor("Hcl"); // 自定義文件命名,注意 %s 會自動填充表實體屬性! gc.setMapperName("%sMapper"); gc.setXmlName("%sMapper"); gc.setServiceName("%sService"); gc.setServiceImplName("%sServiceImpl"); gc.setControllerName("%sController"); mpg.setGlobalConfig(gc); // 數據源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setDbType(DbType.MYSQL); /*dsc.setTypeConvert(new MySqlTypeConvert(){ // 自定義數據庫表字段類型轉換【可選】 public DbColumnType processTypeConvert(String fieldType) { System.out.println("轉換類型:" + fieldType); // 注意!!processTypeConvert 存在默認類型轉換,若是不是你要的效果請自定義返回、非以下直接返回。 return super.processTypeConvert(fieldType); } });*/ dsc.setDriverName("com.mysql.cj.jdbc.Driver"); dsc.setUsername("root"); dsc.setPassword("root"); dsc.setUrl("jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&serverTimezone=Hongkong"); mpg.setDataSource(dsc); // 策略配置 StrategyConfig strategy = new StrategyConfig(); // strategy.setCapitalMode(true);// 全局大寫命名 ORACLE 注意 //strategy.setTablePrefix(new String[] { "tlog_", "tsys_" });// 此處能夠修改成您的表前綴 strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 //strategy.setInclude(new String[]{"app_certificate"}); // 須要生成的表,註釋掉生成所有表 // strategy.setExclude(new String[]{"test"}); // 排除生成的表 // 自定義實體父類 // strategy.setSuperEntityClass("com.baomidou.demo.TestEntity"); // 自定義實體,公共字段 // strategy.setSuperEntityColumns(new String[] { "test_id", "age" }); // 自定義 mapper 父類 // strategy.setSuperMapperClass("com.baomidou.demo.TestMapper"); // 自定義 service 父類 // strategy.setSuperServiceClass("com.baomidou.demo.TestService"); // 自定義 service 實現類父類 // strategy.setSuperServiceImplClass("com.baomidou.demo.TestServiceImpl"); // 自定義 controller 父類 // strategy.setSuperControllerClass("com.baomidou.demo.TestController"); // 【實體】是否生成字段常量(默認 false) // public static final String ID = "test_id"; //strategy.setEntityColumnConstant(true); // 【實體】是否爲構建者模型(默認 false) // public User setName(String name) {this.name = name; return this;} //strategy.setEntityBuilderModel(true); strategy.setTableFillList(tableFillList); mpg.setStrategy(strategy); // 包配置 PackageConfig pc = new PackageConfig(); pc.setParent("com.dofun"); pc.setController("controller"); pc.setXml("mapper"); mpg.setPackageInfo(pc); // 注入自定義配置,能夠在 VM 中使用 cfg.abc 【可無】 ${cfg.abc} InjectionConfig cfg = new InjectionConfig() { @Override public void initMap() { Map<String, Object> map = new HashMap<String, Object>(); map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp"); this.setMap(map); } }; // 自定義 xxListIndex.html 生成 List<FileOutConfig> focList = new ArrayList<FileOutConfig>(); focList.add(new FileOutConfig("/templates/list.html.vm") { @Override public String outputFile(TableInfo tableInfo) { // 自定義輸入文件名稱 return "F:/idea-maven/maven/src/main/resources/static/" + tableInfo.getEntityName() + "ListIndex.html"; } }); cfg.setFileOutConfigList(focList); mpg.setCfg(cfg); // 關閉默認 xml 生成,調整生成 至 根目錄 /*TemplateConfig tc = new TemplateConfig(); tc.setXml(null); mpg.setTemplate(tc);*/ // 自定義模板配置,能夠 copy 源碼 mybatis-plus/src/main/resources/templates 下面內容修改, // 放置本身項目的 src/main/resources/templates 目錄下, 默認名稱一下能夠不配置,也能夠自定義模板名稱 TemplateConfig tc = new TemplateConfig(); tc.setController("/templates/controller.java.vm"); tc.setService("/templates/service.java.vm"); tc.setServiceImpl("/templates/serviceImpl.java.vm"); tc.setEntity("/templates/entity.java.vm"); tc.setMapper("/templates/mapper.java.vm"); tc.setXml("/templates/mapper.xml.vm"); // 如上任何一個模塊若是設置 空 OR Null 將不生成該模塊。 mpg.setTemplate(tc); // 執行生成 mpg.execute(); // 打印注入設置【可無】 System.err.println(mpg.getCfg().getMap().get("abc")); } }
package com.dofun.common; import java.io.Serializable; import java.util.List; public class DatatablesJSON<T> implements Serializable { //當前頁面 private int draw; //總頁數 private long recordsTotal; private long recordsFiltered; // 響應狀態 默認false private Boolean success = false; // 響應消息 private String error; public List<T> getData() { return data; } public void setData(List<T> data) { this.data = data; } // 存放的數據 private List<T> data; public int getDraw() { return draw; } public void setDraw(int draw) { this.draw = draw; } public long getRecordsTotal() { return recordsTotal; } public void setRecordsTotal(long recordsTotal) { this.recordsTotal = recordsTotal; } public long getRecordsFiltered() { return recordsFiltered; } public void setRecordsFiltered(long recordsFiltered) { this.recordsFiltered = recordsFiltered; } public Boolean getSuccess() { return success; } public void setSuccess(Boolean success) { this.success = success; } public String getError() { return error; } public void setError(String error) { this.error = error; } }
package com.dofun.common; import java.io.Serializable; /** * ajax 傳參返回值 */ public class JSONResult<T> implements Serializable { // 響應狀態 默認false private Boolean success = false; // 響應消息 private String message; // 存放的數據 private T data; public JSONResult() { super(); } public Boolean getSuccess() { return success; } public void setSuccess(Boolean success) { this.success = success; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public T getData() { return data; } public void setData(T data) { this.data = data; } }
5. controller 模版 controller.java.vm
apache
package ${package.Controller}; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestMethod; #if(${restControllerStyle}) import org.springframework.web.bind.annotation.RestController; #else import org.springframework.stereotype.Controller; #end #if(${superControllerClassPackage}) import ${superControllerClassPackage}; #end import org.springframework.beans.factory.annotation.Autowired; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import ${package.Service}.${table.serviceName}; import com.dofun.common.DatatablesJSON; import com.dofun.common.JSONResult; import ${package.Entity}.${entity}; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @description : ${entity} 控制器 * @author ${author} * @since ${date} */ #if(${restControllerStyle}) @RestController #else @Controller #end @RequestMapping("#if(${package.ModuleName})/${package.ModuleName}#end/#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end") #if(${superControllerClass}) public class ${table.controllerName} extends ${superControllerClass} { #else public class ${table.controllerName} { #end private final Logger logger=LoggerFactory.getLogger(${table.controllerName}.class); @Autowired public ${table.serviceName} ${table.entityPath}Service; /** * @description : 獲取分頁列表 * --------------------------------- * @author : ${author} * @since : Create in ${date} */ @RequestMapping(value = "/get${entity}List", method = RequestMethod.POST) public Object get${entity}List(${entity} param,@RequestParam(value = "draw", defaultValue = "0") Integer draw, @RequestParam(value = "length") Integer length, @RequestParam(value = "start") Integer start){ DatatablesJSON<${entity}> resJson=new DatatablesJSON<>(); try{ ## Integer pageNo=getPageNo(start,length); Integer pageNo=1; Page<${entity}> page=new Page<${entity}>(pageNo,length); ${table.entityPath}Service.page(page,new QueryWrapper<${entity}>(param)); resJson.setDraw(draw++); resJson.setRecordsTotal(page.getTotal()); resJson.setRecordsFiltered(page.getTotal()); resJson.setData(page.getRecords()); resJson.setSuccess(true); }catch(Exception e){ resJson.setSuccess(false); resJson.setError("異常信息:{"+e.getClass().getName()+"}"); logger.info("異常信息:{}"+e.getMessage()); } return resJson; } /** * @description : 經過id獲取${entity} * --------------------------------- * @author : ${author} * @since : Create in ${date} */ @RequestMapping(value = "/get${entity}ById", method = RequestMethod.GET) public Object get${entity}ById(String id){ JSONResult<${entity}> resJson=new JSONResult<>(); try{ ${entity} param= ${table.entityPath}Service.getById(id); resJson.setData(param); resJson.setSuccess(true); }catch(Exception e){ resJson.setSuccess(false); resJson.setMessage("異常信息:{"+e.getClass().getName()+"}"); logger.info("異常信息:{}"+e.getMessage()); } return resJson; } /** * @description : 經過id刪除${entity} * --------------------------------- * @author : ${author} * @since : Create in ${date} */ @RequestMapping(value = "/delete${entity}ById", method = RequestMethod.GET) public Object delete${entity}ById(String id){ JSONResult<${entity}> resJson=new JSONResult<>(); try{ resJson.setSuccess(${table.entityPath}Service.removeById(id)); }catch(Exception e){ resJson.setSuccess(false); resJson.setMessage("異常信息:{"+e.getClass().getName()+"}"); logger.info("異常信息:{}"+e.getMessage()); } return resJson; } /** * @description : 經過id更新${entity} * --------------------------------- * @author : ${author} * @since : Create in ${date} */ @RequestMapping(value = "/update${entity}ById", method = RequestMethod.POST) public Object update${entity}ById(${entity} param){ JSONResult<${entity}> resJson=new JSONResult<>(); try{ resJson.setSuccess(${table.entityPath}Service.updateById(param)); }catch(Exception e){ resJson.setSuccess(false); resJson.setMessage("異常信息:{"+e.getClass().getName()+"}"); logger.info("異常信息:{}"+e.getMessage()); } return resJson; } /** * @description : 添加${entity} * --------------------------------- * @author : ${author} * @since : Create in ${date} */ @RequestMapping(value = "/add${entity}", method = RequestMethod.POST) public Object add${entity}(${entity} param){ JSONResult<${entity}> resJson=new JSONResult<>(); try{ resJson.setSuccess(${table.entityPath}Service.save(param)); }catch(Exception e){ resJson.setSuccess(false); resJson.setMessage("異常信息:{"+e.getClass().getName()+"}"); logger.info("異常信息:{}"+e.getMessage()); } return resJson; } }
6. html頁面模版 list.html.vm (這個目前生成的頁面和項目並不配套,先預留位置, 後續結合本身項目慢慢研究~)
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> <head th:replace="common/common_header :: common_header(~{::title},~{},~{})"> <title>首頁</title> </head> <body> <section class="content"> <div class="row"> <!-- BEGIN SAMPLE TABLE PORTLET--> <div class="col-md-12"> <!-- BEGIN SAMPLE TABLE PORTLET--> <div class="box-body" style="padding-bottom:0px;"> <div class="panel panel-default"> <div class="panel-heading">高級檢索</div> <div class="panel-body"> <form class="form-inline" method="post" id="searchForm" > <div class="form-group"> <label for="name">角色名</label> <input type="text" class="form-control" id="name" name="name" placeholder="用戶名"/> <input id="hiddenText" type="text" style="display:none" /><!-- 隱藏的 控制回車提交表單--> </div> <button shiro:hasPermission="sys:user:search" type="button" id="btn_query" class="btn btn-success"><i class="fa fa-search"></i> 查詢</button> <button shiro:hasPermission="sys:user:search" type="button" id="btn_reset" class="btn btn-primary"><i class="fa fa-undo"></i> 重置</button> </form> </div> </div> <div id="toolbar" class="btn-group"> <button shiro:hasPermission="sys:user:add" id="btn_add" type="button" class="btn btn-default"> <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增 </button> <button shiro:hasPermission="sys:user:delete" id="btn_delete" type="button" class="btn btn-default" disabled="disabled"> <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>批量刪除 </button> </div> <div class="table-scrollable"> <table class="table-striped table-hover table-bordered" id="empUserList"> </table> </div> </div> <!-- END SAMPLE TABLE PORTLET--> </div> </div> </section> </body> <script th:inline="javascript"> var permissionButton = [];//權限按鈕 </script> <script th:inline="javascript" shiro:hasPermission="sys:user:update"> permissionButton.push('<a class="btn btn-icon-only" data-type="edit" href="javascript:void(0)" title="修改"><i class="glyphicon glyphicon-edit"></i></a>'); </script> <script th:inline="javascript" shiro:hasPermission="sys:user:delete"> permissionButton.push('<a class="btn btn-icon-only" data-type="delete" href="javascript:void(0)" title="刪除"><i class="glyphicon glyphicon-remove"></i></a>'); </script> <div th:replace="common/common_foot :: foot"></div> <script th:src="@{/content/plugins/bootstrap-table/bootstrap-table.js}"></script> <script th:src="@{/content/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.js}"></script> <script th:src="@{/content/common/common.server.js}"></script> <script th:inline="javascript">#macro(dian).#end #set($bootstrapTable = '$table') #macro(tanh)!#end #set($query = '$query') #set($reset = '$reset') #set($remove = '$remove') #set($add = '$add') var $bootstrapTable = $('#empUserList'), $query = $('#btn_query'), $reset = $('#btn_reset'), $remove = $('#btn_delete'), $add = $('#btn_add'), selections = [];//權限按鈕 $(function () { $(".select2").select2(); $bootstrapTable#dian()bootstrapTable({ url: getRootPath()+'/a/${table.entityPath}/get${entity}PageList', queryParams : queryParams, classes: "table-striped table-hover table-bordered", buttonsAlign: "right", //按鈕位置 toolbar: "#toolbar",// 指定工具欄 uniqueId: "id", // 每一行的惟一標識 columns: [ {checkbox : true}, #foreach($field in ${table.fields}) #if(!${field.keyFlag})##生成普通字段 {title: '${field.comment}', field: '${field.propertyName}', align: 'center', valign: 'middle', sortable: true}, #end #end { title: '操做', field: 'id', align: 'center', valign: 'middle', formatter: function (value, row, index) { return permissionButton.join(''); }, events: { 'click [data-type="edit"]': function (e, value, row) { layer_show("修改", getRootPath() + "/a/${table.entityPath}/${table.entityPath}Update?id=" + value, "800", "600"); }, 'click [data-type="delete"]': function (e, value, row) { $.fn.modalConfirm('肯定要刪除所選數據?', function () { $.ajax({ url: getRootPath() + '/a/${table.entityPath}/${table.entityPath}Delete', type: "Post", data: {id: value}, dataType: "json", success: function (result) { if (result > 0) { $.fn.modalMsg("操做成功", "success"); } else { $.fn.modalMsg("操做失敗", "error"); } $remove#dian()prop('disabled', true); $bootstrapTable#dian()bootstrapTable('refresh'); //重新加載數據 } }); }); } } } ], onLoadSuccess: function(){ //加載成功時執行 //layer.msg("加載成功"); }, onLoadError: function(){ //加載失敗時執行 layer.msg("加載數據失敗", {time : 1500, icon : 2}); } }); // sometimes footer render error. setTimeout(function () { $bootstrapTable#dian()bootstrapTable('resetView', { height:getHeight() }); }, 300); $(window).resize(function () { $bootstrapTable#dian()bootstrapTable('resetView', { height:getHeight() }); }); //點擊行中的checkbox 和全選的checkbox事件 $bootstrapTable#dian()on('check.bs.table uncheck.bs.table ' + 'check-all.bs.table uncheck-all.bs.table', function () { $remove#dian()prop('disabled', #tanh()$bootstrapTable#dian()bootstrapTable('getSelections').length); selections = getIdSelections(); }); $query#dian()click(function () { $bootstrapTable#dian()bootstrapTable('refresh'); //重新加載數據 }); $reset#dian()click(function () { $(".form-inline .form-control").val(""); $bootstrapTable#dian()bootstrapTable('refresh'); //重新加載數據 }); $add#dian()click(function () { layer_show("添加", getRootPath()+"/a/${table.entityPath}/${table.entityPath}Add","800","600"); }); $remove#dian()click(function () { if (selections.length < 1) { $.fn.modalAlert('請選擇一條或多條數據進行刪除!','error'); } else { //詢問框 $.fn.modalConfirm ('肯定要刪除所選數據?', function () { $.ajax({ url: getRootPath()+'/a/${table.entityPath}/${table.entityPath}BatchDelete', type: "Post", data:{item:JSON.stringify(selections)}, dataType : "json", success:function(result){ if(result > 0){ $.fn.modalMsg("操做成功","success"); }else { $.fn.modalMsg("操做失敗","error"); } $remove#dian()prop('disabled', true); $bootstrapTable#dian()bootstrapTable('refresh'); //重新加載數據 } }); }); } }); /* input 獲取焦點 才能觸發 刷新事件*/ $("input").keydown(function() { if (event.keyCode == "13") {//keyCode=13是回車鍵 if ($query#dian()length > 0){ $bootstrapTable#dian()bootstrapTable('refresh'); //重新加載數據 } } }); }); /** * 返回全部的checked選中的值 */ function getIdSelections() { return $.map($bootstrapTable#dian()bootstrapTable('getSelections'), function (row) { return row.id }); } /** * 查詢條件與分頁數據 * @param params * @returns {{limit: (*|number), offset, sort, order}} */ function queryParams(params) { var temp = { //這裏的鍵的名字和控制器的變量名必須一直,這邊改動,控制器也須要改爲同樣的 limit: params.limit, //頁面大小 offset: params.offset, //頁碼 sort: params.sort, //排序列名 order:params.order //排序方式 //search:params.search, //搜索框參數 }; getSearchFormData($("#searchForm"),temp); return temp; } </script> </html>