1.若有拦截,请放开需要交互的项目的拦截
@Controller
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/tag")
public class TagComponent extends BaseController {
@RequestMapping("/getTagsByTarget")
public String getInfo(HttpServletRequest request,HttpServletResponse response, String tableName, String target, String userName, String tagUrl) {
response.setHeader("Access-Control-Allow-Origin", "*");
}
}
2,跨域打开的窗口无法跳出关掉的问题:解决方法---------->网页之间通信
$.ajax({
type: "post",url: $("#tagUrl").val()+'/tag/addTag',
data: {mysubdata : JSON.stringify(obj)},
dataType: "json",
success: function(data){
if (data == "success") {
layer.confirm('添加成功!是否关闭窗口?', function(index) {
window.parent.postMessage('layer.close(pageii)','*');
return false;
});
} else {
layer.alert('添加失败!', 3);
}
}
});
window.addEventListener('message',function(e){
eval(e.data);
},false);