This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Bean | |
| public TomcatServletWebServerFactory tomcatEmbedded() { | |
| TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); | |
| tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { | |
| if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol<?>)) { | |
| //-1 means unlimited | |
| ((AbstractHttp11Protocol<?>) connector.getProtocolHandler()).setMaxSwallowSize(-1); | |
| } | |
| }); | |
| return tomcat; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 获取请求参数字典 | |
| function get_params_dict() { | |
| result = {} | |
| if (pm.request.method === "GET") { | |
| for (var i = 0; i < pm.request.url.query.members.length; i++) { | |
| obj = pm.request.url.query.members[i] | |
| result[obj.key] = obj.value | |
| } | |
| } else { | |
| if (pm.request.body.formdata && pm.request.body.formdata.members) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.File; | |
| import java.io.FileInputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.util.*; | |
| public class ConfigReader { | |
| private static final String PROPERTIES_DIR = "properties"; // 配置文件名称 | |
| private static Properties properties = new Properties(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.demo.utils; | |
| import java.util.List; | |
| /** | |
| * @author zhangminpeng on 2016-07-22 14:30 | |
| */ | |
| public class Pagination<T> { | |
| private long pageCurrent; // 当前页码, 起始页码 0 | |
| private long rowCount; // 总记录条数 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @SuppressWarnings("unchecked") | |
| public Pagination<T> list(long pageIndex, long pageSize, Criteria criteria) { | |
| long rowCount = (long) criteria.setProjection(Projections.rowCount()).uniqueResult(); | |
| long pageCount = rowCount % pageSize == 0 ? rowCount / pageSize : rowCount / pageSize + 1; | |
| Pagination<T> pagination = new Pagination<>(); | |
| pagination.setRowCount(rowCount); | |
| pagination.setPageCount(pageCount); | |
| if (pageIndex <= 0) { | |
| pagination.setPageCurrent(0); | |
| pagination.setHasPrevious(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.apache.http.Header; | |
| import org.apache.http.HttpEntity; | |
| import org.apache.http.HttpResponse; | |
| import org.apache.http.client.methods.HttpGet; | |
| import org.apache.http.client.methods.HttpPost; | |
| import org.apache.http.conn.ssl.SSLConnectionSocketFactory; | |
| import org.apache.http.impl.client.CloseableHttpClient; | |
| import org.apache.http.impl.client.HttpClients; | |
| import org.apache.http.ssl.SSLContextBuilder; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // bubble sort(冒泡排序) | |
| public static int[] bubbleSort(int[] array) { | |
| for (int i = 0; i < array.length - 1; i++) { | |
| for (int j = 0; j < array.length - i - 1; j++) { | |
| if (array[j] > array[j + 1]) { | |
| int temp = array[j]; | |
| array[j] = array[j + 1]; | |
| array[j + 1] = temp; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 二分法查询数组中元素所在的位置,数组是有序的,非递归 | |
| public static int dichotomySearch(int[] array, int value) { | |
| int low = 0; | |
| int high = array.length - 1; | |
| while (low <= high) { | |
| int middle = (low + high) / 2; | |
| if (value == array[middle]) { | |
| return middle; | |
| } | |
| if (value > array[middle]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| @ComponentScan | |
| public class Application { | |
| @Bean | |
| MessageService mockMessageService() { | |
| return new MessageService() { | |
| public String getMessage() { | |
| return "Hello Spring"; | |
| } | |
| }; |