问题:我是跳动一个iframe 上传的,上传成功应该关闭它,可是不会关闭
<script type="text/javascript">
//这个是用js掉过去,获不到值
function undo(){
var postData = document.getElementById('uploadFile').value;
console.log(postData);
$.ajax({
url:'undoexcel.action',
dataType:'text',
type:'post',
success:function(data){
if(data.success='success'){
parent.$("#undo",parent.document).window('close');
}else{
alert("导入失败");
}
}
})
}
</script>
//这样可以出来,就是无法关闭iframe
</head>
<body class="body">
<form action="undoexcel.action" enctype="multipart/form-data" method="post" id="ff">
<table width="100%" border="0" align="center">
<tr>
<td colspan="99" id="more">
<input type="file" name="upload" id="uploadFile"/>
<input type="submit" value="上传"/>
<input type="reset" value="重置"/>
</td>
</tr>
</table>
</form>
</body>
//导入
@Action(value = "undoexcel",results={@Result(name="success",location="/WEB-INF/jsp/function/billqq.jsp")})
public String undo() throws Exception{
String directory = "/file";
String targetDirectory = ServletActionContext.getServletContext().getRealPath(directory);
File target = UploadFile.Upload(upload, uploadFileName, targetDirectory);
List<BillEntity> billList = new ArrayList<BillEntity>();
excelFile = new FileInputStream(target);
Workbook workbook = new HSSFWorkbook(excelFile);
Sheet sheet = workbook.getSheetAt(0);
int rowNum = sheet.getLastRowNum() + 1;
for (int i = 1; i < rowNum; i++) {
BillEntity billentity = new BillEntity();
Row row = sheet.getRow(i);
int cellNum = row.getLastCellNum();
for (int j = 0; j < cellNum; j++) {
Cell cell = row.getCell(j);
String cellValue = null;
switch (cell.getCellType()) { // 判断excel单元格内容的格式,并对其进行转换,以便插入数据库
case 0:
cellValue = String
.valueOf((int) cell.getNumericCellValue());
break;
case 1:
cellValue = cell.getStringCellValue();
break;
case 2:
cellValue = String
.valueOf((int) cell.getNumericCellValue());
break;
case 3:
cellValue = cell.getStringCellValue();
break;
case 4:
cellValue = cell.getStringCellValue();
break;
}
switch (j) {// 通过列数来判断对应插如的字段
case 1:
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = formatter.parse(cellValue) ;
billentity.setBi_date(new Timestamp(date.getTime()));
break;
case 2:
billentity.setIncome(Integer.valueOf(cellValue));
break;
case 3:
billentity.setExpend(Integer.valueOf(cellValue));
break;
case 4:
billentity.setRemark(cellValue);
break;
}
}
billList.add(billentity);
}
baseService.add(billList);
return "success";
}
已经都可以上传了,就是关闭不了iframe
https://my.oschina.net/sharkbobo/blog/226978
蹭个评论。请大神帮忙。用的eclipse开发软件,在配置完dtd以后,struts.xml和其他两个配置文件,依然没有提示,请问是什么原因?