405 Post Not Supported

URL 복사 이웃추가 HTTP Status 405 - Request method 'POST' not supported Form에서 보내는 형식과 컨트롤러에서 받는 형식이 달라서 나는 오류로 jsp파일에서 form의 method는 post로 해놓고, ajax통신에서는 get으로 해놓음. The HyperText Transfer Protocol (HTTP) 405 Method Not Allowed response status code indicates that the request method is known by the server but is not supported by the target resource. The server MUST generate an Allow header field in a 405 response containing a list of the target resource's currently supported methods.

Want a custom login form created with JavaConfig? Here's a neat tutorial, which breaks down initial config, additions, and shows you why.

Join the DZone community and get the full member experience.

Join For Free

I have been working on a 100% JavaConfig version of a custom form authentication Spring MVC application. Most examples use XML configuration, but I know I wanted to implement a solution without any XML.

I have investigated several examples, but here is my initial configuration that does work:

I wanted to use a custom login form, so I added this configuration:

Then I added this login.jsp

Now I did test with both /login and /j_security_check as the action.

When using /login, I get an “HTTP 404 Page Not Found” exception, and when I use /j_security_check action, I get a “HTTP Status 405 – Request method ‘POST’ not supported” exception.

I ran across several incidents where using the XML configuration leads to the same error:

But this did not help my specific error.

Here is my updated configuration that finally worked:

I can only surmise, that with the JavaConfig for Spring Security, there are several configuration attributes that are set for the default .formLogin(), and unless you explicitly set these attributes, the login.jsp will not execute the correct action.

security,authentication,authorization

Published at DZone with permission of Mick Knutson, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

2020腾讯云限时秒杀,爆款1核2G云服务器99元/年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062

2020阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址:https://www.aliyun.com/minisite/goods

推荐:HTTP Status 405 - Request method 'POST' not supported (Spring MVC)

HTTP Status 405 - Request method 'POST' not supported (Spring MVC) <html> <head> <meta http-equiv='Content-Type'nofollow'>javaspringspring-boot


this question
edited May 25 at 20:02eis 26k 3 72 104 asked Sep 9 '15 at 12:45 Adelin 4,868 13 55 98
Update the code of TagsController as well. – Rafal G. Sep 9 '15 at 13:55
3
Consider rolling back to revision 2. Right now, the code in your question is correct, making the answer meaningless. – approxiblue Sep 10 '15 at 13:53
@RafalG. the code in question is not supposed to be 'fixed', it breaks the question. – eis May 25 at 20:03
405 Post Not Supported

1 Answers
1

解决方法

You have an error in RestController annotation definition. According to the docs it is:

public @interface RestController {

/** * The value may indicate a suggestion for a logical component name, * to be turned into a Spring bean in case of an autodetected component. * @return the suggested component name, if any * @since 4.0.1 */ String value() default ';

}

推荐:HTTP Status 405 - HTTP method POST is not supported by this URL

今天写了个文件上传的DEMO, 但是再执行上传任务的时候报错 页面错误提示为: HTTP Status 405 - HTTP method POST is not supported by this URL 一直不知错在

Which means the value you have entered ('/backoffice/tags') is NAME of the controller not the path under which it is available.

Add @RequestMapping('/backoffice/tags') on the controller's class and remove value from the @RestController annotation.

EDIT: Fully working example as per comment that it does not work - try to use this code please - and run locally from IDE.

build.gradle

The Keil development team is pleased to announce the availability of Keil MDK-ARM 5.29 is the complete software development environment for a wide range of Arm Cortex-M based microcontroller devices. MDK includes the µVision IDE and debugger, Arm C/C compiler, and essential middleware components. Keil 4 keygen crack. Keil uVision 4 for arm serial numbers, cracks and keygens are presented here. No registration is needed. Just download and enjoy. Keil Uvision 4 keygen: Keil-uvision 8.12 key code generator: Keil-uvision 8.17 serial keygen: Keil Uvision 8.02 keygen: Keil Uvision 3.53 crack.

Tag.java

SampleController.java

DemoApplication.java



this answer
edited May 25 at 19:58Kenny Linsky 1,084 2 12 30 answered Sep 9 '15 at 12:58 Rafal G. 2,104 9 26
Ok, that is one but it still not working .. even after changing it – Adelin Sep 9 '15 at 13:01
Let me reproduce it. Gimme 5 mins. – Rafal G. Sep 9 '15 at 13:02
@Adelin please, see complete working sample. – Rafal G. Sep 9 '15 at 13:12
Spring boot 405 request method

405 Post Not Supported The One

推荐:HTTP Status 405 -- HTTP method POST is not supported by this URL

package web.filter; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServl

  • 1Java开发中的23种设计模式详解
  • 2Spring mvc+hibernate+freemarker(开源项目)
  • 1微信公众号文章采集,并发布到WordPress
  • 2HTTP Status 405 - Request method 'POST' not supported (Spring MVC)
  • 3HTTP Status 405 -- HTTP method POST is not supported by this URL
  • 4HTTP Status 405 - HTTP method POST is not supported by this URL
  • 5HTTP Status 405 - HTTP method GET(POST) is not supported by this URL
  • 6jsp spring mvc 上传时HTTP Status 405 - Request method 'GET' not supported是什么原因

最新文章

Http 405 Post Not Supported

  • 1在阿里架构师眼中构建一个较为通用的业务技术架构就是如此简单
  • 2Java基础类String了解一下
  • 3中国民航飞行学院人事薪资管理系统实践案例
  • 4Java SE——线程介绍
  • 5简单的方法构建一个高可用服务端
  • 6CTO详细讲解海量日志处理ELK