通过servlet打开本地图片
来源:互联网 发布:pk10挂机软件手机软件 编辑:程序博客网 时间:2024/05/21 11:30
//li点击事件 $("#fileul").on("click","#fileli",function(){ //图片格式 var strFilter=".jpeg|.gif|.jpg|.png|.bmp|.pic|"; var path=$(this).attr("path"); var str=(path.substring(path.lastIndexOf('.'),path.length)).toLowerCase(); if(strFilter.indexOf(str)>-1){//后缀是图片格式时才打开 var filepath=parent.window.globedataserverurl + "/OpenImages?filepath="+path;//图片路径 var bheight=$("body",window.parent.document).height();//获取body高度 var bwidth=$("body",window.parent.document).width();//获取body宽度 parent.showImagesDialog(filepath,bheight/5,bwidth/3); } });
package com.globe.servlet;import java.io.FileInputStream;import java.io.IOException;import java.io.OutputStream;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;/** * 打开本地图片 */@WebServlet("/OpenImages")public class OpenImages extends HttpServlet {private static final long serialVersionUID = 1L;private static final String basePath="E:/FTP/武汉局FTP"; public OpenImages() { super(); }protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// 支持跨域访问response.setHeader("Access-Control-Allow-Origin", "*");String filepath = request.getParameter("filepath");filepath = new String(filepath.getBytes("ISO-8859-1"), "UTF-8");//处理请求参数路乱码//读取本地图片输入流 FileInputStream fis = new FileInputStream(basePath+filepath); //得到文件大小 int i = fis.available(); //byte数组用于存放图片字节数据 byte[] buff = new byte[i]; fis.read(buff); fis.close(); //设置发送到客户端的响应内容类型 response.setContentType("image/*"); OutputStream out = response.getOutputStream(); out.write(buff); out.close();}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}}
/** * 打开本地Excel文件 */Desktop.getDesktop().open(new File("c:\SZP5.sql"));
阅读全文
0 0
- 通过servlet打开本地图片
- 通过servlet响应图片
- 通过url打开本地app
- 通过浏览器打开本地Activity
- Webview打开本地图片选择器
- 本地图片选择(打开媒体库,选择图片)
- 本地图片选择(打开媒体库,选择图片)
- 本地图片选择(打开媒体库,选择图片)
- 通过图片URL下载图片到本地
- Android 通过网页链接打开本地应用
- Chrome浏览器通过书签打开本地程序
- 网页通过js打开本地app
- 打开照相机与本地相册选择图片
- Webview打开本地图片文件选择解决方案
- android webview打开本地图片上传
- MFC中Mat实现打开本地图片
- iOS-打开照相机&打开本地相册&图片上传
- 通过路径获取本地图片bitmap
- 小米手机报Installation failed with message Failed to establish session的解决办法
- MySQL笔记——关系模型中的术语
- 微信支付
- Oracle C++ OCCI 编程
- java的几种对象(po,dto,dao等)
- 通过servlet打开本地图片
- # Android LocalSocket and AIDL 传输对象
- 从零开始布置你的个人网站(一)
- JDK8的小常识
- MFC中创建简单定时器
- Nexus 搞机之路 —— aosp源码的获取与编译
- ret,retf,iret的区别
- WPF无边框发送消息改变窗口大小
- 让IE6 IE7 IE8 IE9 IE10 IE11支持Bootstrap的解决方法