window.open弹出窗口调用controller
前台图片调用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的更多相关文章
- 关于window.open弹出窗口被阻止的问题
原文:http://blog.csdn.net/fanfanjin/article/details/6858168 在web编程过程中,经常会遇到一些页面需要弹出窗口,但是在服务器端用window.o ...
- 让IE8在win7下面能显示使用window.showmodaldialog弹出窗口的地址状态栏
问题来源:最近又要对老的系统进行改善,由于用到了window.showmodaldialog这个方法弹出窗口,比如从主界面弹出新增或者修改窗口,如下图所示,显示没有地址栏,进行代码修改还要找到相应的文 ...
- window.open()弹出窗口防止被禁
window.open(),顾名思义,是指在当前浏览器窗口弹出另一个浏览器窗口. 因为多种原因,浏览对window.open弹出的窗口做了多方限制.限制不同,肯定会造成各浏览器弹出窗口的差异. 大部分 ...
- js window.open()弹出窗口参数说明及居中设置
window.open()可以弹出一个新的窗口,并且通过参数控制窗口的各项属性. 最基本的弹出窗口代码 window.open('httP://codeo.cn/'); window.open()各参 ...
- window.open()弹出窗口参数说明及居中设置
window.open()可以弹出一个新的窗口,并且通过参数控制窗口的各项属性. 最基本的弹出窗口代码 window.open('httP://codeo.cn/'); window.open()各参 ...
- window.open()弹出窗口被拦截
之前有个需求是输入一些配置,然后点击预览,通过接口保存配置并返回预览页面链接,在新页面中打开链接.后来测试一直说没有新页面打开,我一看,原来是被浏览器拦截了. 原因如下: 浏览器只有在认为click和 ...
- 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 ...
- 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 ...
- JSP弹出窗口和模式对话框
本文转载于其它blog,在此向本文原创者,致意! JSP 弹出窗口 一.window.open() 基础知识 1.window.open()支持环境: JavaScript1.0+ ...
随机推荐
- 浅谈position: absolute和position:relative
一.在此先说一下文档流的概念: 1,文档流定义: 百度百科定义:文档流是文档中可显示对象在排列时所占用的位置. 大多网友的理解:元素的位置由元素在 (X)HTML 中的位置决定.将窗体自上而下分成一行 ...
- https请求时出错:Could not establish trust relationship for the SSL/TLS secure channel
当我在用NET命名空间下获取URL的时候,提示如下错误: The underlying connection was closed: Could not establish trust relatio ...
- Kali Rolling 下利用rtl-sdr跟踪飞机路线
环境 kali rolling 状态:未升级发行版,仅用 "apt-get upgrade " 命令更新了软件 原料 RTL-SDR电视棒一个,芯片是RTL2832U 原理 我国民 ...
- JS复习:第二十章
一.JSON 1.JSON的语法可以表示以下三种类型的值: (1)简单值:字符串.数值.布尔值和null.如:5,“Hello,World!” (2)对象:javascript中对象字面量: var ...
- POJ 3020 Antenna Placement(无向二分图的最小路径覆盖)
( ̄▽ ̄)" //无向二分图的最小路径覆盖数=顶点总数-最大匹配数/2(最大匹配数=最小点覆盖数) //这里最大匹配数需要除以2,因为每两个相邻的*连一条边,即<u,v>和< ...
- hdu_5324_Boring Class(cdq分治+树状数组)
题目链接:hdu_5324_Boring Class 题意: 给出n个二维点对,求LIS长度和编号字典序最小的LIS(x非增,y非减) 题解: dp[i]=max(dp[j]) (i>j,l[i ...
- Lynis 2.2.0 :面向Linux系统的安全审查和扫描工具
Lynis是一款功能非常强大的开源审查工具,面向类似Unix/Linux的操作系统.它可以扫描系统,查找安全信息.一般的系统信息.已安装软件及可用软件信息.配置错误.安全问题.没有设密码的用户帐户.错 ...
- WimTool(Wim映像处理工具) V1.30.2011.501 免费绿色版
软件名称: WimTool(Wim映像处理工具) V1.30.2011.501 免费绿色版软件语言: 简体中文授权方式: 免费软件运行环境: Win7 / Vista / Win2003 / WinX ...
- Pivot Index--Google
Return the pivot index of the given array of numbers. The pivot index is the index where the sum of ...
- 关于maven相互依赖的工程部署问题
环境:win7 64位,myeclipse10.6,eclipse4.5,都配置了svn插件 问题描述:1.工程模块化之后都是通过pom配置model来关联的,svn提交之后,通过myeclipse的 ...