标签:
①在ViewAllPlat项目中包com.baosight.viewall.common下建立类FileTool,继承Applet,类中添加如下方法:
/** * @author DongMingWang * @time 20150807 * @return filePath */ public String selectFilePath() { try{ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.showDialog(null, "选择"); File file = jfc.getSelectedFile(); if (file != null) return file.getAbsolutePath(); }catch(Exception e){ e.printStackTrace(); } return "c:\\hisvideo"; }
②将该类打包成FileTool.jar文件放入项目WebContent下的applet路径下
③在页面ZJSP02.jsp中添加如下代码引用applet:
<applet id="filePathChoose" CODE = "com.baosight.viewall.common.FileTool" codebase="applet/" archive="FileTool.jar" width="0" height="0"></applet>
④在文件ZJSP02.js中添加如下方法调用上面的java方法
/**
* @author DongMingWang
* @time 20150804
* 文件路径选择
*/
function selectFilePath()
{
var filePath = filePathChoose.selectFilePath();
$(id_txtPath).val(filePath);
}
NOTICE:此法需待客户端有jre环境,且涉及安全性问题时,需在打applet的jar包时进行签名认证.
标签:
原文地址:http://www.cnblogs.com/cangyu/p/4711046.html