您的位置:首页 > Web前端 > JQuery

一周乱弹(1,摸态框增加纵向滚动条2,jQuery 鼠标点击事件3,通过ajax实现批量导出。4,windows查询占用某个端口号程序并杀死其进程)

2016-08-21 21:04 811 查看
1,摸态框增加纵向滚动条
在摸态框的body标签上增加:style="height: 600px;overflow: auto"

2 jQuery 鼠标点击事件。

$(function(){
$('a').mousedown(function(e){
alert(e.which) // 1 = 鼠标左键 left; 2 = 鼠标中键; 3 = 鼠标右键
return false;//阻止链接跳转
})
})



$('#downwps2010').mousedown(function(e){
if(3 == e.which){
alert('这 是右键单击事件');

}else if(1 == e.which){
alert('这 是左键单击事件');

}
})
js代码:
function exportComment(classesId) {
//得到班级学生id
var url1 = "train/review-stu-find/" + classesId;
$.get(url1, function (resp) {
var students = resp.data;
//ajax动态导出
for(index in students) {
var url2 = "train/classes-situation-export/"+classesId+"/"+students[index].id+"?"+Math.random();//这个为我的导出时href的连接,
window.open(url2,"_blank");
}

}, "json");
}


3,通过ajax实现批量导出。
说明:ajax 其实只是一个javascript中的一个组建 XmlHttpRequest, 他的作用是数据交互, 返回数据是组件内部处理的, 下载是需要浏览器识别http头的,所以如果想实现导出功能,后台要设置response响应头等相关信息
后台代码举例:
/* HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/msword; charset=utf-8");
response.setHeader("Content-Disposition","attachment;filename="+wname);
response.setCharacterEncoding("utf-8");
OutputStream outfa = response.getOutputStream();*/
@RequestMapping(value = "/approve-export/{formId}",method = RequestMethod.GET)
@ResponseBody
public void exportApprove(@PathVariable("formId")String formId,HttpServletRequest request,HttpServletResponse response)throws Exception{
HWPFDocument hwpf = this.getBaseAllService().getSchoolBusinessApproveService().exportApproveInfo(formId, request);
response.addHeader("Content-Disposition", "attachment;filename=" + FileNameEncoderUtil.encode(request,"来校经商申请表.doc"));
response.setContentType("application/vnd.ms-excel");
OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
hwpf.write(toClient);
toClient.flush();
toClient.close();
}  其中_blank必须加上,如果写成_self,虽然是循环打开但是后一个会把前一个覆盖,所以最终只会得到一个。
4,windows查询占用某个端口号程序并杀死其进程。
查询占用某个端口号
netstat -aon | findstr "1688"
查看其程序名称
tasklist | findstr "1688"
结束进程
taskkill /pid  1688  /F 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐