搜索词>>map工具 耗时0.1410
  • Java编程之Map与Java bean之间的转换工具类

    Map与Java bean之间的转换工具类,用于java.util.Map与普通javabean直接的相互转换,Java编程Java编程之Map与Java bean之间的转换工具类,用于java.util.Map与普通javabean直接的相互转换<br /> 工具代码清单:<br /> MapUtils.java: <pre> <code class="language-java">import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; public class MapUtils { /** * javaBean 转 Map * * @param object * 需要转换的javabean * @return 转换结果map * @throws Exception */ public static Map<String, Object> beanToMap(Object object) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); @SuppressWarnings("rawtypes") Class cls = object.getClass(); Field[] fields = cls.getDeclaredFields(); for (Field field : fields) { field.setAccessible(true); map.put(field.getName(), field.get(object)); } return map; } /** * * @param map * 需要转换的map * @param cls * 目标javaBean的类对象 * @return 目标类object * @throws Exception */ public static Object mapToBean(Map<String, Object> map, @SuppressWarnings("rawtypes") Class cls) throws Exception { Object object = cls.newInstance(); for (String key : map.keySet()) { Field temFiels = cls.getDeclaredField(key); temFiels.setAccessible(true); temFiels.set(object, map.get(key)); } return object; } } </code></pre> <br /> 利用了Java语言的反射机制
  • Linux后台下载工具(器)transmission 使用详解

    Linux后台下载工具(器)transmission 类似迅雷使用详解,transmission 是一款支持绝大多数Linux系统的下载工具,采用web进行管理。可以通过web添加bt下载文件下载任务也可以直接指定下载url进行下载,一切皆在web中完成,这对Linux来说简直是一个下载神器啊。transmission简述Linux后台下载工具(器)transmission 使用详解,transmission 是一款支持绝大多数Linux系统的下载工具,采用web进行管理。可以通过web添加bt下载文件下载任务也可以直接指定下载url进行下载,一切皆在web中完成,这对Linux来说简直是一个下载神器啊。
  • Apache httpclient4.5 GET/POST/PUT/OPTION/DELETE工具类

    Apache httpclient4.5 GET/POST/PUT/OPTION/DELETE工具类Apache httpclient4.5 GET/POST/PUT/OPTION/DELETE工具类<br /> <br /> 该工具类使用比较新的<br /> Apache httpclient4.5版本<br /> <br /> 支持GET请求、POST请求、DELETE请求、PATCH请求、PUT请求、DELETE请求、OPTIONS请求<br /> <br /> 工具类代码如下: <pre> <code class="language-java"> import org.apache.http.Header; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.*; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URI; import java.nio.charset.Charset; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * 工具类 httpclient4.5 * * @author xq */ public class HttpclientUtils { private final static Logger logger = LoggerFactory.getLogger(HttpclientUtilss.class); /** * post请求 json参数 * * @param url * @param bodyJsonParams * @param headers * @return * @throws IOException */ public static String doPost(String url, String bodyJsonParams, Map<String, String> headers) throws IOException { HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Content-Type", "application/json"); httpPost.setEntity(new StringEntity(bodyJsonParams, Charset.forName("UTF-8"))); addHeader(httpPost, headers); return execute(httpPost); } /** * post k-v参数 * * @param url * @param params * @param headers * @return * @throws IOException */ public static String doPost(String url, Map<String, String> params, Map<String, String> headers) throws IOException { HttpPost httpPost = new HttpPost(url); if (params != null && params.keySet().isEmpty()) { httpPost.setEntity(getUrlEncodedFormEntity(params)); } addHeader(httpPost, headers); return execute(httpPost); } /** * patch json参数 * * @param url * @param bodyJsonParams * @param headers * @return * @throws IOException */ public static String doPatch(String url, String bodyJsonParams, Map<String, String> headers) throws IOException { HttpPatch httpPatch = new HttpPatch(url); httpPatch.setEntity(new StringEntity(bodyJsonParams)); addHeader(httpPatch, headers); return execute(httpPatch); } /** * patch k-v参数 * * @param url * @param params * @param headers * @return * @throws IOException */ public static String doPatch(String url, Map<String, String> params, Map<String, String> headers) throws IOException { HttpPatch httpPatch = new HttpPatch(url); if (params != null && !params.isEmpty()) { httpPatch.setEntity(getUrlEncodedFormEntity(params)); } addHeader(httpPatch, headers); return execute(httpPatch); } /** * PUT JSON参数 * * @param url * @param bodyJsonParams * @param headers * @return * @throws IOException */ public static String doPut(String url, String bodyJsonParams, Map<String, String> headers) throws IOException { HttpPut httpPut = new HttpPut(url); httpPut.addHeader("Content-Type", "application/json"); httpPut.setEntity(new StringEntity(bodyJsonParams, Charset.forName("UTF-8"))); addHeader(httpPut, headers); return execute(httpPut); } /** * put k-v参数 * * @param url * @param params * @param headers * @return * @throws IOException */ public static String doPut(String url, Map<String, String> params, Map<String, String> headers) throws IOException { HttpPut httpPut = new HttpPut(url); if (params != null && params.keySet().isEmpty()) { httpPut.setEntity(getUrlEncodedFormEntity(params)); } addHeader(httpPut, headers); return execute(httpPut); } /** * Delete json 参数 * * @param url * @param bodyJsonParams * @param headers * @return * @throws IOException */ public static String doDeletedoPut(String url, String bodyJsonParams, Map<String, String> headers) throws IOException { HttpDeleteWithEntity httpDelete = new HttpDeleteWithEntity(url); httpDelete.setEntity(new StringEntity(bodyJsonParams)); addHeader(httpDelete, headers); return execute(httpDelete); } /** * delete k-v参数 * * @param url * @param params * @param headers * @return * @throws IOException */ public static String doDelete(String url, Map<String, String> params, Map<String, String> headers) throws IOException { HttpDeleteWithEntity httpDelete = new HttpDeleteWithEntity(url); addHeader(httpDelete, headers); if (params != null && !params.isEmpty()) { httpDelete.setEntity(getUrlEncodedFormEntity(params)); } return execute(httpDelete); } /** * options json参数 * * @param url * @param bodyJsonParams * @param headers * @return * @throws IOException */ public static String doOptions(String url, String bodyJsonParams, Map<String, String> headers) throws IOException { HttpOptionsWithEntity httpOptions = new HttpOptionsWithEntity(url); addHeader(httpOptions, headers); httpOptions.setEntity(new StringEntity(bodyJsonParams)); return execute(httpOptions); } /** * options k-v参数 * * @param url * @param params * @param headers * @return * @throws IOException */ public static String doOptions(String url, Map<String, String> params, Map<String, String> headers) throws IOException { HttpOptionsWithEntity httpOptions = new HttpOptionsWithEntity(url); addHeader(httpOptions, headers); if (params != null && !params.isEmpty()) { httpOptions.setEntity(getUrlEncodedFormEntity(params)); } return execute(httpOptions); } /** * head请求 * * @param url * @param headers * @return * @throws IOException */ public static String doHeader(String url, Map<String, String> headers) throws IOException { HttpHead httpHead = new HttpHead(url); addHeader(httpHead, headers); return execute(httpHead); } /** * get请求 * * @param url * @param params * @param headers * @return * @throws IOException * @throws ClientProtocolException */ public static String doGet(String url, Map<String, String> params, Map<String, String> headers) throws IOException { // 参数 StringBuilder paramsBuilder = new StringBuilder(url); if (params != null && params.keySet().isEmpty()) { if (url.indexOf("?") == -1) { paramsBuilder.append("?"); } List<NameValuePair> list = new ArrayList<>(); Set<String> keySet = headers.keySet(); Iterator<String> iterator = keySet.iterator(); while (iterator.hasNext()) { String key = iterator.next(); String value = headers.get(key); list.add(new BasicNameValuePair(key, value)); } String paramsStr = EntityUtils.toString(new UrlEncodedFormEntity(list)); paramsBuilder.append(paramsStr); } HttpGet httpGet = new HttpGet(paramsBuilder.toString()); // 头 addHeader(httpGet, headers); return execute(httpGet); } /** * 执行请求并返回string值 * * @param httpUriRequest * @return * @throws IOException */ private static String execute(HttpUriRequest httpUriRequest) throws IOException { try (CloseableHttpClient httpClient = HttpClients.createDefault()) { CloseableHttpResponse response = httpClient.execute(httpUriRequest); // if (response.getStatusLine().getStatusCode() == 200) {// 请求成功状态 // try (BufferedReader bufferedReader = new BufferedReader( // new InputStreamReader(response.getEntity().getContent()))) { // StringBuilder sb = new StringBuilder(); // String tmp; // while ((tmp = bufferedReader.readLine()) != null) { // sb.append(tmp); // } // return sb.toString(); // } // } Header type = response.getEntity().getContentType(); logger.debug("Type:" + type.getValue()); String defaultCharset = "UTF-8"; String charset = getCharSet(type.getValue()); if (!StringUtils.isEmpty(charset)) { defaultCharset = charset; } return EntityUtils.toString(response.getEntity(), defaultCharset); } // return null; } /** * 添加请求头部 * * @param httpUriRequest * @param headers */ private static void addHeader(HttpUriRequest httpUriRequest, Map<String, String> headers) { if (httpUriRequest != null) { if (headers != null && !headers.keySet().isEmpty()) { Set<String> keySet = headers.keySet(); Iterator<String> iterator = keySet.iterator(); while (iterator.hasNext()) { String key = iterator.next(); String value = headers.get(key); httpUriRequest.addHeader(key, value); } } } } /** * 获取 UrlEncodedFormEntity 参数实体 * * @param params * @return * @throws UnsupportedEncodingException */ private static UrlEncodedFormEntity getUrlEncodedFormEntity(Map<String, String> params) throws UnsupportedEncodingException { if (params != null && params.keySet().isEmpty()) { List<NameValuePair> list = new ArrayList<>(); Set<String> keySet = params.keySet(); Iterator<String> iterator = keySet.iterator(); while (iterator.hasNext()) { String key = iterator.next(); String value = params.get(key); list.add(new BasicNameValuePair(key, value)); } return new UrlEncodedFormEntity(list); } return null; } /** * 根据HTTP 响应头部的content type抓取响应的字符集编码 * * @param content * @return */ private static String getCharSet(String content) { String regex = ".*charset=([^;]*).*"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(content); if (matcher.find()) return matcher.group(1); else return null; } /** * 解决httpclient 的DELETE默认不支持setEntity */ static class HttpDeleteWithEntity extends HttpEntityEnclosingRequestBase { public static final String METHOD_NAME = "DELETE"; @Override public String getMethod() { return METHOD_NAME; } public HttpDeleteWithEntity(final String uri) { super(); setURI(URI.create(uri)); } public HttpDeleteWithEntity(final URI uri) { super(); setURI(uri); } public HttpDeleteWithEntity() { super(); } } /** * 解决httpclient 的OPTIONS默认不支持setEntity */ static class HttpOptionsWithEntity extends HttpEntityEnclosingRequestBase { public static final String METHOD_NAME = "OPTIONS"; @Override public String getMethod() { return METHOD_NAME; } public HttpOptionsWithEntity() { super(); } public HttpOptionsWithEntity(final String uri) { super(); setURI(URI.create(uri)); } public HttpOptionsWithEntity(final URI uri) { super(); setURI(uri); } } public static void main(String[] args) { } } </code></pre>  
  • Java编程使用zip打包文件(压缩文件)和解包(加压文件) 工具实现

    这里主要讲解在Java编程中如何使用zip算法来打包文件、文件集合和解压一个zip包的工具类。该工具类主要通过Apache的compress项目中衍生出来的。比Java原生的压缩方式灵活和方便。<ul> <li> <h2>1.说明</h2> zip的文件压缩和解压在文件的存放用的还是比较多的。这里写了一个zip的工具类通过Apache的compress依赖实现。方便移植。</li> <li> <h2>2.依赖</h2> <pre> <code class="language-xml"> <!-- 压缩 --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-compress</artifactId> <version>1.14</version> </dependency></code></pre> </li> </ul> <h2> </h2> <ul> <li> <h2>3.工具类实现</h2> <pre> <code class="language-java">package net.xqlee.project.utils.compress; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.compress.archivers.zip.Zip64Mode; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.lang.StringUtils; import net.xqlee.project.utils.exception.UtilException; /** * zip压缩算法工具类 * * @author xq * @JDK 1.7 */ public class ZipCompressUtils { private ZipCompressUtils() { // 禁止构造 } /** 缓冲大小 **/ public static final int BUFFER_SIZE = 1024; /** 系统默认字符集 **/ public static final String SYSTEM_ENCODING = System.getProperty("file.encoding"); /** * 解压zip文件,默认操作系统字符集编码 * * @param zipFile * @param destDir * @return * @throws UtilException */ public static List<String> unZip(final File zipFile, final String targetPath) throws UtilException { try { return unZip(new FileInputStream(zipFile), targetPath, SYSTEM_ENCODING); } catch (FileNotFoundException e) { throw new UtilException(e); } } /** * 指定zip字符集解压文件 * * @param zipFile * @param targetPath * @param encoding * @return * @throws UtilException */ public static List<String> unZip(final File zipFile, final String targetPath, String encoding) throws UtilException { try { return unZip(new FileInputStream(zipFile), targetPath, encoding); } catch (FileNotFoundException e) { throw new UtilException(e); } } /** * 解压zip文件流 * * @param zipFileInputStream * @param targetPath * @return * @throws UtilException */ public static List<String> unZip(final InputStream zipFileInputStream, final String targetPath) throws UtilException { return unZip(zipFileInputStream, targetPath, SYSTEM_ENCODING); } /** * 解压 zip 文件 * * @param zipFileInputStream * zip 压缩文件流 * @param destDir * zip 压缩文件解压后保存的目录 * @return 返回 zip 压缩文件里的文件名的 list * @throws UtilException * 工具类处理的异常 */ public static List<String> unZip(final InputStream zipFileInputStream, final String destDir, final String encoding) throws UtilException { // 如果 destDir 为 null, 空字符串, 或者全是空格, 则解压到压缩文件所在目录 String targetDir = ""; if (StringUtils.isBlank(destDir)) { throw new UtilException("Target Path Can't Be Empty!"); } else { targetDir = destDir.endsWith(File.separator) ? destDir : destDir + File.separator; } // 字符集处理 String fileEncoding = encoding; if (StringUtils.isBlank(encoding)) { fileEncoding = SYSTEM_ENCODING; } List<String> fileNames = new ArrayList<>(); try (ZipArchiveInputStream is = new ZipArchiveInputStream( new BufferedInputStream(zipFileInputStream, BUFFER_SIZE), fileEncoding);) { ZipArchiveEntry entry = null; while ((entry = is.getNextZipEntry()) != null) { String fileName = entry.getName(); fileNames.add(fileName); if (entry.isDirectory()) { File directory = new File(targetDir, fileName); directory.mkdirs(); } else { try (OutputStream os = new BufferedOutputStream(new FileOutputStream(new File(targetDir, fileName)), BUFFER_SIZE);) { IOUtils.copy(is, os); } } } } catch (Exception e) { throw new UtilException(e); } return fileNames; } /** * zip打包 * * @param files * @param zipFilePath * @throws UtilException */ public static void zip(File[] files, String zipFilePath,String encoding) throws UtilException { if (files == null || files.length == 0) { throw new UtilException("Files Is Null Or Empty!"); } try { File zipFile = new File(zipFilePath); try (ZipArchiveOutputStream zipos = new ZipArchiveOutputStream(zipFile)) { //字符集 zipos.setEncoding(encoding); // 启用64模式 zipos.setUseZip64(Zip64Mode.AsNeeded); // 将每个文件用ZipArchiveEntry封装 // 再用ZipArchiveOutputStream写到压缩文件中 for (File file : files) { if (file != null && file.exists() && file.isFile()) { ZipArchiveEntry archiveEntry = new ZipArchiveEntry(file, file.getName()); zipos.putArchiveEntry(archiveEntry); try (InputStream is = new BufferedInputStream(new FileInputStream(file));) { byte[] buffer = new byte[BUFFER_SIZE * 4]; int len = -1; while ((len = is.read(buffer)) != -1) { // 把缓冲区的字节写入到ZipArchiveEntry zipos.write(buffer, 0, len); } // Writes all necessary data for this entry. zipos.closeArchiveEntry(); } } } zipos.finish(); } } catch (Exception e) { throw new UtilException(e); } } /** * 压缩某个目录 * * @param dir * @param zipFilePath * @throws UtilException */ public static void zip(String dir, String zipFilePath,String encoding) throws UtilException { if (StringUtils.isBlank(dir) || StringUtils.isBlank(zipFilePath)) { throw new UtilException("Dir To Package Or Zip File Can't Be Empty"); } Map<String, File> filesInfo = filesName(dir, dir); Set<String> keys = filesInfo.keySet(); // try { File zipFile = new File(zipFilePath); try (ZipArchiveOutputStream zipos = new ZipArchiveOutputStream(zipFile)) { if (!StringUtils.isBlank(encoding)) { zipos.setEncoding(encoding); } // 启用64模式 zipos.setUseZip64(Zip64Mode.AsNeeded); // 将每个文件用ZipArchiveEntry封装 // 再用ZipArchiveOutputStream写到压缩文件中 Iterator<String> iterator = keys.iterator(); while (iterator.hasNext()) { String string = (String) iterator.next(); File file = filesInfo.get(string); ZipArchiveEntry archiveEntry = new ZipArchiveEntry(file, string); zipos.putArchiveEntry(archiveEntry); try (InputStream is = new BufferedInputStream(new FileInputStream(file));) { byte[] buffer = new byte[BUFFER_SIZE * 4]; int len = -1; while ((len = is.read(buffer)) != -1) { // 把缓冲区的字节写入到ZipArchiveEntry zipos.write(buffer, 0, len); } // Writes all necessary data for this entry. zipos.closeArchiveEntry(); } } zipos.finish(); } } catch (Exception e) { throw new UtilException(e); } } public static Map<String, File> filesName(String dirPath, String rootPath) { Map<String, File> fileInfo = new HashMap<>(); File dir = new File(dirPath); if (dir.exists() && dir.isDirectory()) { File[] files = dir.listFiles(); for (File file : files) { if (file.isDirectory()) { Map<String, File> fs = filesName(file.getPath(), rootPath); fileInfo.putAll(fs); } else { fileInfo.put(file.getPath().replace(rootPath, ""), file); } } } return fileInfo; } public static void main(String[] args) throws UtilException { // String zipPath = "C:\\Users\\xq\\Desktop\\李小强工作交接内容.zip"; // String destDir = "C:\\Users\\xq\\Desktop\\zip"; // unZip(new File(zipPath), destDir); // 打包 // File dir = new File(destDir); // zip(dir.listFiles(), destDir + "\\test.zip"); zip("C:\\Users\\xq\\Desktop\\zip", "C:\\Users\\xq\\Desktop\\test.zip",null); } } </code></pre> 工具类最后有调用方式。</li> </ul> <br />  
  • 黑群晖安装transmission下载工具

    黑群晖安装transmission下载工具黑群晖安装transmission下载工具
  • jquery图片查看插件Viewer.js使用讲解

    jquery插件Viewer.js是一个强大的图片查看工具,Viewer也提供了一个纯js版本的工具,图片查看,Viewer.js,Viewerjquery插件Viewer.js是一个强大的图片查看工具,Viewer也提供了一个纯js版本的工具<br /> GITHUB地址:<a href="https://github.com/fengyuanchen/viewer" rel="nofollow" target="_blank">https://github.com/fengyuanchen/viewer</a><br /> 效果:<br /> <img alt="viewer图片查看器,图片一" class="img-thumbnail" src="/assist/images/blog/9f3b079c3e8c4a61a3d2af0e54dab3de.png" /><br /> <span style="color:#16a085">提示:本站图片查看也是采用该工具</span><br /> 使用:<br /> JavaScript版本 <pre> <code class="language-xml"><link rel="stylesheet" href="css/viewer.min.css"> <script src="js/viewer.min.js"></script></code></pre> <br /> jQuery 版本: <pre> <code class="language-xml"><link rel="stylesheet" href="css/viewer.min.css"> <script src="js/jquery.min.js"></script> <script src="js/viewer.min.js"></script></code></pre> 注意:JS 版本和 jQuery 版本名字虽然一样,但代码不一样,不能通用,请到 github 上下载需要的版本。<br />   <h3>HTML</h3> <pre> <code class="language-xml"><ul id="dowebok"> <li><img src="img/tibet-1.jpg" alt="图片1"></li> <li><img src="img/tibet-2.jpg" alt="图片2"></li> <li><img src="img/tibet-3.jpg" alt="图片3"></li> <li><img src="img/tibet-4.jpg" alt="图片4"></li> <li><img src="img/tibet-5.jpg" alt="图片5"></li> <li><img src="img/tibet-6.jpg" alt="图片6"></li> </ul></code></pre>   <h3>JavaScript:</h3> JavaScript版本: <pre> <code class="language-javascript">var viewer = new Viewer(document.getElementById('dowebok'));</code></pre> jQuery 版本: <pre> <code class="language-javascript">$('#dowebok').viewer();</code></pre> <br /> 参数使用 <pre> <code class="language-javascript">$('#dowebok').viewer({ navbar:false,//关闭缩略导航 toolbar:false//关闭工具栏 });</code></pre> <br /> 其他配置参数: <table class="table table-bordered table-hover"> <thead> <tr> <th>名称</th> <th>类型</th> <th>默认值</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>inline</td> <td>布尔值</td> <td>false</td> <td>启用 inline 模式</td> </tr> <tr> <td>button</td> <td>布尔值</td> <td>true</td> <td>显示右上角关闭按钮(jQuery 版本无效)</td> </tr> <tr> <td>navbar</td> <td>布尔值/整型</td> <td>true</td> <td>显示缩略图导航</td> </tr> <tr> <td>title</td> <td>布尔值/整型</td> <td>true</td> <td>显示当前图片的标题(现实 alt 属性及图片尺寸)</td> </tr> <tr> <td>toolbar</td> <td>布尔值/整型</td> <td>true</td> <td>显示工具栏</td> </tr> <tr> <td>tooltip</td> <td>布尔值</td> <td>true</td> <td>显示缩放百分比</td> </tr> <tr> <td>movable</td> <td>布尔值</td> <td>true</td> <td>图片是否可移动</td> </tr> <tr> <td>zoomable</td> <td>布尔值</td> <td>true</td> <td>图片是否可缩放</td> </tr> <tr> <td>rotatable</td> <td>布尔值</td> <td>true</td> <td>图片是否可旋转</td> </tr> <tr> <td>scalable</td> <td>布尔值</td> <td>true</td> <td>图片是否可翻转</td> </tr> <tr> <td>transition</td> <td>布尔值</td> <td>true</td> <td>使用 CSS3 过度</td> </tr> <tr> <td>fullscreen</td> <td>布尔值</td> <td>true</td> <td>播放时是否全屏</td> </tr> <tr> <td>keyboard</td> <td>布尔值</td> <td>true</td> <td>是否支持键盘</td> </tr> <tr> <td>interval</td> <td>整型</td> <td>5000</td> <td>播放间隔,单位为毫秒</td> </tr> <tr> <td>zoomRatio</td> <td>浮点型</td> <td>0.1</td> <td>鼠标滚动时的缩放比例</td> </tr> <tr> <td>minZoomRatio</td> <td>浮点型</td> <td>0.01</td> <td>最小缩放比例</td> </tr> <tr> <td>maxZoomRatio</td> <td>数字</td> <td>100</td> <td>最大缩放比例</td> </tr> <tr> <td>zIndex</td> <td>数字</td> <td>2015</td> <td>设置图片查看器 modal 模式时的 z-index</td> </tr> <tr> <td>zIndexInline</td> <td>数字</td> <td>0</td> <td>设置图片查看器 inline 模式时的 z-index</td> </tr> <tr> <td>url</td> <td>字符串/函数</td> <td>src</td> <td>设置大图片的 url</td> </tr> <tr> <td>build</td> <td>函数</td> <td>null</td> <td>回调函数,具体查看演示</td> </tr> <tr> <td>built</td> <td>函数</td> <td>null</td> <td>回调函数,具体查看演示</td> </tr> <tr> <td>show</td> <td>函数</td> <td>null</td> <td>回调函数,具体查看演示</td> </tr> <tr> <td>shown</td> <td>函数</td> <td>null</td> <td>回调函数,具体查看演示</td> </tr> <tr> <td>hide</td> <td>函数</td> <td>null</td> <td>回调函数,具体查看演示</td> </tr> <tr> <td>hidden</td> <td>函数</td> <td>null</td> <td>回调函数,具体查看演示</td> </tr> <tr> <td>view</td> <td>函数</td> <td>null</td> <td>回调函数,具体查看演示</td> </tr> <tr> <td>viewed</td> <td>函数</td> <td>null</td> <td>回调函数,具体查看演示</td> </tr> </tbody> </table>
  • 视频压缩软件-免费视频压缩工具推荐

    视频压缩工具推荐,这里给大家推荐一款免费开源的视频压缩工具,视频压缩功能强大且免费哟。提供视频压缩软件VidCoder下载地址,包含安装版和免安装版下载。视频压缩工具推荐,这里给大家推荐一款免费开源的视频压缩工具,视频压缩功能强大且免费哟。
  • spring mvc采用mapping代码方式配置项目的默认首页注意事项

    spring mvc采用mapping代码方式配置项目的默认首页注意事项,spring mvc,默认首页,spring<p>1.默认tomcat容器的默认页面。 <br />  </p> <pre> <code>/index.html </code></pre> <p><br /> <br /> 这种方式适合访问静态的页面(也包括JSP)或者说是没有任何参数的页面。</p> <p>2.spirng mvc 默认index controller 方式 <br /> 如果在tomcat容器没有配置默认页面,怎spring mvc 会主动去寻找/index的controller,如果有则会调用,没有则会显示404页面。 </p> <pre> <code class="language-java">@RequestMapping(value=”/index”)  public ModelAndView index(HttpServletRequest request, HttpServletResponse response){  return new ModelAndView(“index”);  }</code></pre> <p>3.spirng mvc 配置根节点访问“/”方式 <br /> 这种方法比较极端,就是配置一个名为“/”的controller,就是输入完网址之后就会调用。这种方法是前面两种方法都没有配置的时候。 </p> <pre> <code class="language-java">@RequestMapping(value=”/”) public ModelAndView index(HttpServletRequest request, HttpServletResponse response){ return new ModelAndView(“index”); }</code></pre> <p>三种方法的级别高低:1>>3>>2;因为tomcat的容器级别比spring要高,以上3钟配置都存在的情况,优先使用tomcat。因为配置了”/”的controller,所以会先匹配到相关的controller,而不会先寻找/index controller.</p> <p><span style="color:#e74c3c"><strong>注意,即使web.xml没有添加,tomcat也会自动默认去寻找在webroot目录下面的index文件,如果要使用后面两种方法,</strong></span><span style="color:#27ae60"><strong>则要保证webroot下面没有index相关的文件</strong></span><span style="color:#e74c3c"><strong>。<br /> <br /> 注意!注意!注意!<br /> 重要的事情说三遍。。。<br /> 如果webroot存在index.html文件<br /> 并且在代码中将index.html路径重定向到了/<br /> 则会发生无限重定向问题.导致首页不能访问。</strong></span><br /> <br />  </p>
  • Java编程中base64图片与文件图片的相互转化工具

    Java编程中处理图片文件与base64串的图片相互转化工具类,方便在编程中处理前端传递过来的base64图片。1.依赖包,maven引入 <pre> <code class="language-xml"> <!--Base64Encoder等工具类 --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.10</version> </dependency> <!--/Base64Encoder等工具类 --></code></pre> 2.Java编程代码: <pre> <code class="language-java">package com.leftso.common; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.imageio.ImageIO; import org.apache.commons.codec.binary.Base64; /** * 图片与base64编码的互转工具 * * @author leftso * */ public class ImageBase64Util { public static void main(String[] args) { try { File image = new File("C:\\Users\\fghfghdf\\Desktop\\temp\\2.png"); String imageStr = image2Base64(new FileInputStream(image)); System.out.println(imageStr); File out = new File("C:\\Users\\fghfghdf\\Desktop\\temp\\3.png"); base642Image(imageStr, new FileOutputStream(out)); } catch (Exception e) { e.printStackTrace(); } } /** * 图片文件转换为base64编码的串 * * @param imageFileInputStream * 图片文件输入流 * @return 编码后的base64串 * @throws IOException * 可能出现IO异常 */ public static String image2Base64(InputStream imageFileInputStream) throws IOException { byte[] data = new byte[imageFileInputStream.available()]; imageFileInputStream.read(data); imageFileInputStream.close(); Base64 base64 = new Base64(); return base64.encodeAsString(data); } /** * base64串转换为图片文件 * * @param base64Image * 图片base64串 * @param outputStream * 输出流 * @throws IOException * 可能出现IO异常 */ public static void base642Image(String base64Image, OutputStream outputStream) throws IOException { Base64 base64 = new Base64(); // 解码 byte[] imageArr = base64.decode(base64Image); InputStream sbs = new ByteArrayInputStream(imageArr); BufferedImage bufferImg = ImageIO.read(sbs); ImageIO.write(bufferImg, "PNG", outputStream); } } </code></pre> <br /> <strong><span style="color:#FF0000">注意<br /> 前端传递过来的图片,一般会有一个前缀,如下<br /> "data:image/jpeg;base64," <br /> 解码之前去掉,否则错误。</span></strong><br />  
  • Zerotier网络管理_Zerotier免费稳定内网穿透工具

    据上一篇zerotier账号注册_zerotier免费稳定内网穿透工具 初步介绍了Zerotier和Zerotier的网络图,这篇主要针对Zerotier的网络管理基础操作进行讲解据上一篇zerotier账号注册_zerotier免费稳定内网穿透工具 初步介绍了Zerotier和Zerotier的网络图,这篇主要针对Zerotier的网络管理基础操作进行讲解。1​创建一个网络首先登录到Zerotier管理后台,登录方式参考zerotier账号注册_zerotier免费稳定内网穿透工具 文中有详细讲解。登录后切换到网络管理栏目,如下图:​ 接下来点击蓝色的Create Networ按钮,就可以创建一个子网络组了,创建后如下图:​上面的信息初步讲解下,ID 很重要,后续的客户端会通过这个ID进行join进这个网络组里面来。前面的文字描述也就是这一个意思。Zerotier管理子网络组 点击上面这个子网络,进入到管理界面:​网络管理主要有 Settings/Members/Flow Rules/Sharing几个模块。这里的模块是我收缩的,默认打开是展开的应该看起来很多东西的样子。下面进行Settings (设置)进行操作 基础设置界面:​在基础设置中,可以对网络组的名称/说明/接入方式进行修改。其中Access Control 的两个选择意思是,Private(客户端JOIN后需要审核),Public 不需要审核接下来是高级设置:​高级设置中,主要对路由进行设置,可以选择路由网段等操作。还有个就是能手动通过成员节点ID添加成员设备。成员设备管理​ 这里由于没有设备连接所以看起来是空的。如果有设备则是一个列表形式展示。下面是一个有成员的界面:​成员管理还有个新界面:​网络规则配置网络规则配置有点类似Linux系统的防火墙配置,普通用户这里默认即可不用改动。分享操作最后是一个分享的操作,授权分享设备出去。这个看需求一般也用不到。跳过了。删除网络组点击下面的红色Delete Network按钮进行删除:​​勾选上面的Yes...在点击确认删除。网络基础管理讲解完毕,下一步将会讲解成员添加和删除​