gpt4 book ai didi

java - 通过 servlet 发送字节,得到 "HTTP method GET is not supported by this URL"

转载 作者:可可西里 更新时间:2023-11-01 16:24:50 25 4
gpt4 key购买 nike

我有以下代码...

  @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doGet(req, resp);
final int idValue = Integer.parseInt(req.getParameter("id"));
final ProjectRunEntity projectRunEntity = projectDataService.findProjectRunEntity(idValue);
try {
final byte[] documentAsBytes = wordFileGenerationService.getDocumentAsBytes(projectRunEntity);
resp.setContentType("application/msword");
resp.setHeader("Content-Disposition", "inline; filename=example.doc;");
final ServletOutputStream out = resp.getOutputStream();
out.write(documentAsBytes);
out.flush();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

它获取一些恰好是 word 文档的字节并将它们写入 servlet 响应。出于某种原因,当我点击 url 时,我在浏览器中收到以下消息...

"HTTP Status 405 - HTTP method GET is not supported by this URL"

我在 Tomcat 6 上。有什么想法吗?我知道我的调试器没有任何问题,正在将字节写入响应的输出流。

最佳答案

我猜这个错误是由默认的 doGet 实现抛出的(当你调用 super.doGet(req, resp) 时)。

关于java - 通过 servlet 发送字节,得到 "HTTP method GET is not supported by this URL",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3103203/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com