Google Chrome上的response.setHeader错误

时间:2013-11-29 10:19:27

标签: java jsp google-chrome button response

这是一个关于JSP的项目。 1)我有这个代码,按下按钮,动作呈现给另一个页面,这是一个包含pdf的JSP页面,用户可以保存它。 我在一个月前尝试了我的代码并且它工作正常,现在当我尝试它时,它不起作用于chrome,但是在mozilla上工作。 这是代码行

 response.setHeader("Content-Disposition", "inline; filename=Question.pdf");

2)我的第二个问题是,我有一个重置按钮,这个按钮重置数据库。这个功能在chrome上工作正常但在mozilla上没有。我不知道为什么它没有,根本没有动作发生。 这是

的代码行
<button type="button" onclick="reset.jsp"><a href="reset.jsp">RESET</a></button>

1 个答案:

答案 0 :(得分:0)

问题1): 我从"content-disposition", "attachment;filename=somefile.ext""content-disposition", "inline;filename=somefile.ext"之间的区别所知,在inline情况下,浏览器会尝试单独呈现它,如果不能,它会提示用户下载它。也许在你的情况下你有一个Chrome的扩展,能够在浏览器中显示PDF文件,现在没有。见Content-Disposition:What are the differences between "inline" and "attachment"?

关于问题2): 此代码onclick="reset.jsp"不是有效的构造。 Onclick 必须是有效的JavaScript函数。见http://www.w3schools.com/jsref/event_onclick.asp。而且你没有必要拥有它,因为你在按钮内部有一个执行实际操作的链接。我猜Chrome会忽略此错误而MOzilla不会。尝试从按钮中删除onclick="reset.jsp"