获取JSON弹出窗口以保存或打开对话框而不是实际内容? [英] Getting JSON popup to save or open dialog instead of actual content?
问题描述
我的问题:json字符串作为文件返回。当我调用getJSONResult操作时,它会给我一个带有json字符串的文件,我可以打开或下载。
My Problem: The json string returns as a file. When i call the getJSONResult action it will give me a file with the json string in it, which i can open or download.
我认为这是一个配置问题,但是我找不到它。如果有人可以帮助我,我会很高兴,谢谢你们!
I think it’s a configuration problem, but i can’t find it. I would be very glad if somebody could help me, thanks guys!
我有一个开头表格,其中包含一个使用动作和执行方法获取数据的提交。然后,我可以让jquery工作的唯一方法是放置一个动作并执行只返回'success'的方法然后我用第三个动作进入我的jquery网格。
I have an opening form with a submit that uses an action and execute method to get the data. Then, the only way I could get jquery to work was to put an action and execute method that just returns 'success' and then I go onto my jquery grid with a 3rd action.
struts.xml
struts.xml
<struts>
<package name="live" namespace="/live" extends="struts-default,json-default">
<action name="gridAction" class="core.action.AdminAction">
<result name="success" type="json"></result>
<result name="error">/live/YYY.jsp</result>
</action>
</package>
</struts>
推荐答案
我假设您使用的是Internet Explorer,因为我谷歌浏览器从来没有遇到过这个问题(甚至还有一个插件可以很好地和漂亮地格式化它: https://chrome.google.com/webstore/detail/chklaanhfefbnpoihckbnefhakgolnmc )
I assume you're using Internet Explorer, because I've never gotten this problem with Google Chrome (and there's even a plug-in that formats it all nicely and prettily: https://chrome.google.com/webstore/detail/chklaanhfefbnpoihckbnefhakgolnmc)
搜索四周,我想出两页为你的问题提供相同的解决方案,如果你确实使用的是IE:
Searching around, I've come up with two pages that offer the same solution to your problem, if indeed you are using IE:
我怎样才能说服IE简单地显示application / json而不是提议下载吗?
Th解决方案的主要依据在于:
The main gist of the solution lies here:
需要在IE中查看JSON响应吗?
Need to view JSON responses in IE?
-
打开记事本并粘贴以下内容:
Open Notepad and paste the following:
Windows Registry Editor Version 5.00;
; Tell IE 7,8,9 to open JSON documents in the browser on Windows XP and later.
; 25336920-03F9-11cf-8FD0-00AA00686F13 is the CLSID for the "Browse in place" .
;
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\text/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
注意:这已经在Windows XP和Windows 7上使用IE 7,8,9进行了测试。
这篇关于获取JSON弹出窗口以保存或打开对话框而不是实际内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!