前台图片调用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. PHP全角半角转换函数

    之前试过网上找的通过ASCII之类的字符替换,发现很多莫名其妙的问题.最后还是换成下面的字符替换方式了,把目前能找到的所有全角都列出来了一个个替换吧 /** * 全角字符转换为半角 * * @para ...

  2. iOS开发Embedded dylibs/frameworks are only supported on iOS 8.0 and later for architecture armv7的解决方法

    全局搜索IPHONEOS_DEPLOYMENT_TARGE改为更小的版本

  3. ManyToMany OrderBy

    有A.B表和A_B中间表,A_B中间表只有A.B表的id,想让A中的bs以date列排序: @Entity @Table(name="A") public class A impl ...

  4. 明天学习一下验证码的匹配和thinkphp第十三章

    333333333 js 冒泡排序 var arr=[17,19,5,90,3];window.onload=function(){// alert(arr[0]);var len=arr.lengt ...

  5. (负)-margin在页面布局中的应用

    有关margin的原理可以看看这篇文章:http://www.cnblogs.com/2050/archive/2012/08/13/2636467.html#2457812 有关margin负值的几 ...

  6. hdu 5469 Antonidas(树的分治+字符串hashOR搜索+剪枝)

    题目链接:hdu 5469 Antonidas 题意: 给你一颗树,每个节点有一个字符,现在给你一个字符串S,问你是否能在树上找到两个节点u,v,使得u到v的最短路径构成的字符串恰好为S. 题解: 这 ...

  7. jquery 固定导航

    网页代码: <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> & ...

  8. Lucene基础(1)

    下一篇: Lucene基础(2) 一.Lucene介绍 http://www.kailing.pub/index/columns/colid/16.html Documentation:http:// ...

  9. 不创建类将json数据转换

    一般,取到json数据之后,都会将json数据转换为对象,通过属性取得里面的属性值,这样做可以很好地利用vs的智能提示,让开发更轻松,但是代价就是,你需要手动的创建json数据相对应的类. 也有其他方 ...

  10. Leetcode018 4Sum

    public class S018 { //借鉴S015,速度有些慢 public List<List<Integer>> fourSum(int[] nums, int ta ...