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+ ...
随机推荐
- jquery选择器之基本筛选选择
1.基本选择器 2.内容筛选选择器 3.可见性筛选选择器 4.属性筛选选择器 5.子元素筛选选择器 6.表单元素选择器 7.表单对象属性筛选器
- NPM使用介绍
NPM是随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署的很多问题,常见的使用场景有以下几种: 允许用户从NPM服务器下载别人编写的第三方包到本地使用 允许用户NPM服务器下载并安装别 ...
- ACdream 1064 完美数
数位dp. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #incl ...
- cookie模拟
1 为什么要使用cookie模拟 从日常项目测试过程中的问题说起. 比如要进行论坛中的文件下载功能的测试.我们都知道只有登录用户才能进行下载操作,这样我们的测试过程可能 ...
- js--数组去重3种方法
js数组去重的三种常用方法总结 第一种是比较常规的方法 思路: 1.构建一个新的数组存放结果 2.for循环中每次从原数组中取出一个元素,用这个元素循环与结果数组对比 3.若结果数组中没有该元素,则存 ...
- java 导出excel(简单案例)
public class Student { private int id; private String name; private int age; private Date birth; pub ...
- webpack - tree shaking
Tree-shaking with webpack 2 and Babel 6 babel-webpack-tree-shaking Ben Levwis
- PerformSelector 和 NSInvocation
- html readonly和disabled的区别
今天我创建了一个html表单,其中一个字段是sequence number, 这个字段是用ajax异步从后台获取自动生成的,我不希望用户修改这个值,于是我使用了如下html代码来处理: <for ...
- Linux中kettle自动化部署脚本
自己写的一个自动化在Linux中部署kettle的脚本,包括一些遇到的问题在脚本中都有涉及. kettle是官网最新版本pdi-ce-6.1.0.1-196.zip 目前最新版本下载地址:https: ...