HTTP 状态 405 - JSP 只允许 GET POST 或 HEAD [英] HTTP Status 405 - JSPs only permit GET POST or HEAD

查看:24
本文介绍了HTTP 状态 405 - JSP 只允许 GET POST 或 HEAD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自 JSP 2.3 (Tomcat 8) 起,JSP 唯一支持的方法是 GET POST 或 HEAD:

Since JSP 2.3 (Tomcat 8) only supported method for JSP is GET POST or HEAD:

https://jcp.org/aboutJava/communityprocess/maintenance/jsr245/245-MR3.htmlhttp://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/JspServlet.java?view=diff&r1=1497877&r2=1497878&pathrev=1497878

但是,我想,这是一个很大的不兼容更改,例如,对于异常处理程序,它用于转发到 JSP 以呈现异常和 iso JSP 视图,因为 JSP 2.3 响应是:

But, I suppose, it is a big incompatible change as, for example, for exception handler it is used to forward to JSP for rendering exception and iso JSP view since JSP 2.3 response is:

Method Not Allowed
HTTP Status 405 - JSPs only permit GET POST or HEAD 

description The specified HTTP method is not allowed for the requested resource.
Apache Tomcat/8.0.3

如果我们在异常情况下使用 REST 和 Spring HandlerExceptionResolver,我们肯定会遇到这个问题.是否有解决此问题的方法(iso 更改 http 方法类型)?

If we use REST and Spring HandlerExceptionResolver in case of exception we bump into this problem for sure. Are there any workaround for this problem (iso change http method type)?

推荐答案

抱歉,没有解决方法(目前).我对 EG 的建议是处理的方法是可配置的.该建议被拒绝.我建议您向他们提出这个具体问题,因为这是使支持的方法在每个 JSP(或 JSP 组)的基础上进行配置的一个很好的论据.

Sorry, there is no workaround (at the moment) for this. My recommendation to the EG was that the handled methods were made configurable. That suggestion was rejected. I suggest you raise this specific issue with them since it is a good argument for making the supported methods configurable on a per JSP (or group of JSPs) basis.

与此同时,我将看看在您为此提出的错误下使用某种形式的 Tomcat 特定配置进行配置:https://issues.apache.org/bugzilla/show_bug.cgi?id=56568

Meanwhile, I'll take a look at making this configurable using some form of Tomcat specific configuration under the bug you raised for this: https://issues.apache.org/bugzilla/show_bug.cgi?id=56568

更新:从 Tomcat 8.0.9 开始,当使用 JSP 生成错误页面时,将允许使用任何 HTTP 方法.

UPDATE: As of Tomcat 8.0.9 when a JSP is used to generate an error page, any HTTP method will be allowed.

这篇关于HTTP 状态 405 - JSP 只允许 GET POST 或 HEAD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆