高密专业网站建设价格,58同城做网站多少钱,90设计网站官网首页,郑州建站优化在项目中要用到jsp页面实现网页采集摄像头图像#xff0c;并实现上传的功能#xff0c;页面主要js调用的#xff0c;所以可以使用多种语言php,asp等都可以使用#xff0c;而且是跨浏览器的。可以整合的到SSH项目中和struts1或者struts2项目中使用方法1#xff1a;下载 pri…在项目中要用到jsp页面实现网页采集摄像头图像并实现上传的功能页面主要js调用的所以可以使用多种语言php,asp等都可以使用而且是跨浏览器的。可以整合的到SSH项目中和struts1或者struts2项目中使用方法1下载 printscreen4web-jsp.war(最下面有下载地址),然后放到tamcat目录webapp文件夹下面启动tomcat访问http://127.0.0.1:8080/printscreen4web-jsp/主要调用文件 1.index.html.2avatar.jspString imagepath1;//编辑页面中包含 camera.swf 的 HTML 代码public String renderHtml(String id,String basePath,String input){String outinput;try {outinput URLDecoder.decode(input);}catch(Exception e){System.out.println(解码错误!);}String[] tmp_inputoutinput.split();//input传递的类型和uid//System.out.println(input,tmp_input.length);String uc_api URLEncoder.encode(basePathupload/avatar.jsp);String urlCameraFlash camera.swf?nt1inajax1appid1inputinputuploadSize1000ucapiuc_api;urlCameraFlash ;return urlCameraFlash;}public String getFileExt(String fileName) {// 下面取到的扩展名错误只有三位而如html的文件则有四位// extName fileName.substring(fileName.length() - 3, fileName.length()); //扩展名int dotindex fileName.lastIndexOf(.);String extName fileName.substring(dotindex, fileName.length());extName extName.toLowerCase(); //置为小写return extName;}private byte[] getFlashDataDecode(String src){char []ssrc.toCharArray();int lens.length;byte[] r new byte[len / 2];for (int i 0; i len; i i 2){int k1 s[i] - 48;k1 - k1 9 ? 7 : 0;int k2 s[i 1] - 48;k2 - k2 9 ? 7 : 0;r[i / 2] (byte)(k1 4 | k2);}return r;}public boolean saveFile(String path,byte[]b){try{FileOutputStream fs new FileOutputStream(path);fs.write(b, 0, b.length);fs.close();return false;}catch(Exception e){return true;}}%String uploadtype request.getParameter(uploadtype);//图片上传类型:头像,logo,图片分别对应参数:head,logo,pic没有传递默认为PICif(.equals(uploadtype)){uploadtypepic;}//最终裁剪好的图片存放位置String uidrequest.getParameter(uid);imagepath1uploadtype/uid_big.jpg;String action request.getParameter(a);//String inputrequest.getParameter(input);String path request.getContextPath();String infoFilePath;String basePath request.getScheme()://request.getServerName():request.getServerPort()path/;if(actionnull){%body{margin: 0;border: 0;}function updateavatar() {var img1;if(window.opener.document.getElementById(imgpath1)){window.opener.document.getElementById(imgpath1).valueimg1;window.opener.document.getElementById(showimg1).srcupload/img1;}window.close();}out.print(renderHtml(5,basePath,URLEncoder.encode(uploadtypeuid)));%}else if(uploadavatar.equals(action)){//上传临时图片,可以自己实现//System.out.println(action);UploadUtil uploadUtil new UploadUtil();boolean isOk uploadUtil.initParam(pageContext,request);if (isOk false){System.out.println(页面出错 uploadUtil.getMsg());return;}//上传附件isOk uploadUtil.uploadFile();if (isOk false){System.out.println(页面出错 uploadUtil.getMsg());return;}Map map uploadUtil.getUploadFiles();if (map null){System.out.println(页面出错上传附件失败);}if (map.size() 0){System.out.println(页面出错没有上传附件);return;}//获取附件文件名和存储文件路径for (Iterator iter map.keySet().iterator(); iter.hasNext();){infoFilePath (String) iter.next();String infoFileName (String) map.get(infoFilePath);//infoFilePathinfoFilePath.substring(infoFilePath.lastIndexOf(\\)1);//System.out.println(infoFilePath);//infoFilePathinfoFilePath.substring(infoFilePath.indexOf(webapps)8);infoFilePathinfoFilePath.replaceAll(\\\\, /);//System.out.println(basePathuploadinfoFilePath);out.clear();out.print(basePathuploadinfoFilePath);}}else if(rectavatar.equals(action)){//缩略图String avatar1 request.getParameter(avatar1);//大String avatar2 request.getParameter(avatar2);//中String avatar3 request.getParameter(avatar3);//小String output ;try {output URLDecoder.decode(request.getParameter(input));}catch(Exception e){System.out.println(解码错误!);}String[] tmp_inputoutput.split();//input传递的类型和uidString pathff request.getSession().getServletContext().getRealPath(/) upload\\;String imgfilepathpathfftmp_input[0];imagepath1imgfilepath/tmp_input[1]_big.jpg;out.clear();boolean a1saveFile(imagepath1,getFlashDataDecode(avatar1));if(a1){out.print(?xml version\1.0\ ?);}else{out.print(?xml version\1.0\ ?);}}%