前台图片调用js函数

<img src='${pageContext.request.contextPath}/FlatUI/img/link.png' id='report' alt='"+data[i].report+"' onclick='changeUrl(this,"+data[i].id+")' width=15px height=15px/>

js函数, 其中有一项重要处理, 在open窗口关闭的同时, 当前窗口刷新

function changeUrl(element,id){
//alert(element.alt);
//window.open("/trip/changeUrl?id="+id);
var winObj = window.open ("/portal/trip/changeUrl?id="+id+"&item="+element.id+"&value="+element.alt, "newwindow", "height=100, width=800, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no, top=50,left=1100");
var loop = setInterval(function() {
if(winObj.closed) {
clearInterval(loop);
//alert('closed');
window.location.reload();
}
}, 1);
}

controller端 /portal/trip/changeUrl

@RequestMapping("/changeUrl")
public String changeUrl(Long id, String item, String value, HttpServletRequest request){
request.setAttribute("id",id);
request.setAttribute("item",item);
request.setAttribute("value",value);
//System.out.println(id);
return "/tripController/tripURL";
}

tripURL.jsp, 其中有个处理, 提交保存后, 关闭当前页面

<form action="/portal/trip/updateTrip" onsubmit="window.opener=null;window.close();">
<font size="2" color="#004779"> Change URL To:</font><br/>
<input type="hidden" name="id" id="id" value="${id }">
<input type="hidden" name="item" id="item" value="${item }">
<input type="text" name="value" id="value" value="${value }" style="color:#95a5a6; padding-left:5px;border-radius:5px; width:700px; height:28px; vertical-align:middle;">
<input type="submit" value="Save" style="color:#2c3e50; font-size:12px;font-weight:bold; border-radius:5px; vertical-align:middle;height:30px; width:60px; "/>
</form>

controller端 /portal/trip/updateTrip

@RequestMapping("/updateTrip")
public String updateTrip(Long id,String item,String value,HttpServletResponse response){
//String result = "{\"result\":\"success\"}";
try {
URLDecoder.decode(value,"utf-8");
} catch (Exception e) {
e.printStackTrace();
} tripService.updateById(id,item,value); JSONObject data = new JSONObject();
try {
data.put("result", "success");
} catch (Exception e) {
System.out.println(e.getMessage());
} PrintWriter out = null;
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
try {
out=response.getWriter();
out.write(data.toString());
out.flush();
out.close();
return null;
} catch (IOException e) {
e.printStackTrace();
}
return "redirect:/trip/getAllTrip";
}

window.open弹出窗口调用controller的更多相关文章

  1. 关于window.open弹出窗口被阻止的问题

    原文:http://blog.csdn.net/fanfanjin/article/details/6858168 在web编程过程中,经常会遇到一些页面需要弹出窗口,但是在服务器端用window.o ...

  2. 让IE8在win7下面能显示使用window.showmodaldialog弹出窗口的地址状态栏

    问题来源:最近又要对老的系统进行改善,由于用到了window.showmodaldialog这个方法弹出窗口,比如从主界面弹出新增或者修改窗口,如下图所示,显示没有地址栏,进行代码修改还要找到相应的文 ...

  3. window.open()弹出窗口防止被禁

    window.open(),顾名思义,是指在当前浏览器窗口弹出另一个浏览器窗口. 因为多种原因,浏览对window.open弹出的窗口做了多方限制.限制不同,肯定会造成各浏览器弹出窗口的差异. 大部分 ...

  4. js window.open()弹出窗口参数说明及居中设置

    window.open()可以弹出一个新的窗口,并且通过参数控制窗口的各项属性. 最基本的弹出窗口代码 window.open('httP://codeo.cn/'); window.open()各参 ...

  5. window.open()弹出窗口参数说明及居中设置

    window.open()可以弹出一个新的窗口,并且通过参数控制窗口的各项属性. 最基本的弹出窗口代码 window.open('httP://codeo.cn/'); window.open()各参 ...

  6. window.open()弹出窗口被拦截

    之前有个需求是输入一些配置,然后点击预览,通过接口保存配置并返回预览页面链接,在新页面中打开链接.后来测试一直说没有新页面打开,我一看,原来是被浏览器拦截了. 原因如下: 浏览器只有在认为click和 ...

  7. JavaScript BOM-11-BOM的核心-window对象; window对象的控制,弹出窗口方法; 超时调用; 间歇调用; location对象常用属性; 位置操作--location.reaplace,location.reload(); BOM中的history对象; Screen对象及其常用属性; Navigator对象;

    JavaScript BOM 学习目标 1.掌握什么是BOM 2.掌握BOM的核心-window对象 3.掌握window对象的控制.弹出窗口方法 什么是bom BOM(browser object ...

  8. Add an Action that Displays a Pop-up Window 添加显示弹出窗口按钮

    In this lesson, you will learn how to create an Action that shows a pop-up window. This type of Acti ...

  9. JSP弹出窗口和模式对话框

    本文转载于其它blog,在此向本文原创者,致意!    JSP 弹出窗口  一.window.open() 基础知识      1.window.open()支持环境:  JavaScript1.0+ ...

随机推荐

  1. Webpack学习笔记(二)

    市面上已经存在的模块管理和打包工具并不适合大型的项目,尤其单页面 Web 应用程序.最紧迫的原因是如何在一个大规模的代码库中,维护各种模块资源的分割和存放,维护它们之间的依赖关系,并且无缝的将它们整合 ...

  2. Eight

    Eight 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1043/http://acm.split.hdu.edu.cn/showproblem.ph ...

  3. loadrunner 计数器

    http://wenku.baidu.com/link?url=oN2kBiABHE1xJmbmZdOmlTCz0sJ8aL3i-hVGiBjAtw-epUW7qrk4f2mAqdOeK5xXw8Sk ...

  4. 真正实现Netty私有协议开发

    首先<Netty权威指南>私有协议开发那一章的样例代码是编译不通过的(但是这丝毫不影响本书的价值)处理方案可以参考:http://www.itnose.net/detail/6112870 ...

  5. [妙味DOM]第六课:鼠标滚轮和COOKIE

    知识点总结: 鼠标滚轮事件 存在兼容性问题: IE/chorme : onmousewheel FF : DOMMouseScroll,必需用在addEventListener下,例如: if (ob ...

  6. iOS-Runtime机制详解

    一.简介 runtime是一套底层的纯c语言的API,我们写的代码在程序运行过程中都会被转化成runtime的C代码执行,例如[target doSomething];会被转化成objc_msgSen ...

  7. HttpClient, HttpClientHandler, and WebRequestHandler介绍

    注:本文为个人学习摘录,原文地址:https://blogs.msdn.microsoft.com/henrikn/2012/08/07/httpclient-httpclienthandler-an ...

  8. 对Big O的新的认识

    对Big O的新的认识 一个问题,它有很多种算法都能实现.每种算法它的时间.空间复杂度不一样.比如: 问题1: 求最大连续子序列和的问题,可以有O(n3).O(n2).O(nlogn)和O(n)四种时 ...

  9. Redis持久存储-AOF&RDB

    Redis中数据存储模式有2种:cache-only,persistence;cache-only即只做为"缓存"服务,不持久数据,数据在服务终止后将消失,此模式下也将不存在&qu ...

  10. HDU1503:Advanced Fruits(LCS)

    Problem Description The company "21st Century Fruits" has specialized in creating new sort ...