Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Resolved the problem of the request method 'post' not supported.
Next
Answered
John O'Sullivan
  • 7
John O'Sullivan
Asked: May 18, 20222022-05-18T15:31:47+00:00 2022-05-18T15:31:47+00:00In: java

Resolved the problem of the request method ‘post’ not supported.

  • 7

. Advertisement .

..3..

. Advertisement .

..4..

I am working on java, but I found the following warning message:

Request method 'POST' not supported

Is there any way to stabilize the issue “request method ‘post’ not supported”? I read a lot of topics about this, but all of them were trying to install anything. Is this the correct way, or any recommendation for me? Please find the beginning command below:

@RestController
 @RequestMapping("/employeeapp/employees")
 public class EmployeeController {
 
  private final EmployeeService service;
 
  @Autowired
  public EmployeeController(EmployeeService service) {
  this.service = service;
  }
 
  @RequestMapping(method = RequestMethod.POST)
  @ResponseStatus(HttpStatus.CREATED)
  public
  @ResponseBody
  Employee create(@RequestBody @Valid Employee employeeEntry) {
  return service.create(employeeEntry);
  }
 
  @RequestMapping(value = "{id}", method = RequestMethod.DELETE)
  public Employee delete(@PathVariable("id") long id) {
  return service.delete(id);
  }
 
  @RequestMapping(method = RequestMethod.GET)
  public List<Employee> findAll() {
  return service.findAll();
  }
 
  @RequestMapping(value = "{id}", method = RequestMethod.GET)
  public Employee findById(@PathVariable("id") long id) {
  return service.findById(id);
  }
 
  @RequestMapping(value = "{id}", method = RequestMethod.PUT)
  public Employee update(@RequestBody @Valid Employee employeeEntry) {
  return service.update(employeeEntry);
  }
 
  @ExceptionHandler
  @ResponseStatus(HttpStatus.NOT_FOUND)
  public void handleEmployeeNotFound(EmployeeNotFoundException exception) {
  }
 
 }
@SpringBootApplication
 public class Application {
  public static void main(String[] args) throws Exception {
  SpringApplication.run(Application.class, args);
  }
 }
{
  "id" : 1,
  "name" : "nikhil",
  "dept" : "DCX"
 }
2016-02-19 12:21:36.549 INFO 5148 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] :
 Initializing Spring FrameworkServlet 'dispatcherServlet'
 2016-02-19 12:21:36.549 INFO 5148 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet :
 FrameworkServlet 'dispatcherServlet': initialization started
 2016-02-19 12:21:36.562 INFO 5148 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet :
 FrameworkServlet 'dispatcherServlet': initialization completed in 13 ms
 2016-02-19 12:21:36.595 WARN 5148 --- [nio-8080-exec-1] o.s.web.servlet.PageNotFound :
 Request method 'POST' not supported
[INFO] --- spring-boot-maven-plugin:1.3.2.RELEASE:run (default-cli) @ EmployeeApp ---
 
  . ____ _ __ _ _
  /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
 ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  ' |____| .__|_| |_|_| |_\__, | / / / /
  =========|_|==============|___/=/_/_/_/
  :: Spring Boot :: (v1.3.2.RELEASE)
 
 2016-02-19 14:51:00.690 INFO 5080 --- [ main] app.Application : Starting Application on DIN16003277 with PID 5080 (D:\!Nikhil\Documents\Code\EmployeeApp\target\classes started by nvibhav in D:\!Nikhil\Documents\Code\EmployeeApp)
 2016-02-19 14:51:00.693 INFO 5080 --- [ main] app.Application : No active profile set, falling back to default profiles: default
 2016-02-19 14:51:00.770 INFO 5080 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]46117566: startup date [Fri Feb 19 14:51:00 IST 2016]; root of context hierarchy
 2016-02-19 14:51:01.987 INFO 5080 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
 2016-02-19 14:51:02.567 INFO 5080 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
 2016-02-19 14:51:03.026 INFO 5080 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
 2016-02-19 14:51:03.037 INFO 5080 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
 2016-02-19 14:51:03.039 INFO 5080 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.30
 2016-02-19 14:51:03.172 INFO 5080 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
 2016-02-19 14:51:03.173 INFO 5080 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2409 ms
 2016-02-19 14:51:03.689 INFO 5080 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'metricFilter' to: [/*]
 2016-02-19 14:51:03.689 INFO 5080 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
 2016-02-19 14:51:03.690 INFO 5080 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
 2016-02-19 14:51:03.690 INFO 5080 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
 2016-02-19 14:51:03.690 INFO 5080 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
 2016-02-19 14:51:03.691 INFO 5080 --- [ost-startStop-1] .e.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
 2016-02-19 14:51:03.691 INFO 5080 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
 2016-02-19 14:51:03.691 INFO 5080 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
 2016-02-19 14:51:03.692 INFO 5080 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
 2016-02-19 14:51:04.011 INFO 5080 --- [ost-startStop-1] b.a.s.AuthenticationManagerConfiguration :
 
 Using default security password: c652ec29-f926-40eb-bb5b-2bd9185bf6a5
 
 2016-02-19 14:51:04.075 INFO 5080 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant [pattern='/js/**'], Ant [pattern='/images/**'], Ant [pattern='/**/favicon.ico'], Ant [pattern='/error']]], []
 2016-02-19 14:51:04.141 INFO 5080 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: [email protected]1, [org.springframework.secu[email protected]71d64e0f, org.spring[email protected]68e32d1f, [email protected]3e4, org.[email protected]6a766ce6, org.sp[email protected]3111b148, org.springframework.security.web.servletapi.Securit[email protected], org.springfram[email protected]289e0d8f, o[email protected]4ec4999b, org[email protected]3f4e33f9]
 2016-02-19 14:51:04.181 INFO 5080 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.boot.actuate.autoconfigure.Manage[email protected]7f2a96e1, [org.springframework.secu[email protected]3ae13235, org.spring[email protected]5f36bdc8, [email protected]520, org.[email protected]1ce1dc64, org.springfram[email protected]51a29584, org.sp[email protected]120723a8, org.springframework.[email protected]b2632d, org.springfram[email protected]49cabfed, o[email protected]6c8e082f, org[email protected]51f381ff, org.springfr[email protected]3b3223fd]
 2016-02-19 14:51:04.399 INFO 5080 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot[email protected]46117566: startup date [Fri Feb 19 14:51:00 IST 2016]; root of context hierarchy
 2016-02-19 14:51:04.471 INFO 5080 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
 2016-02-19 14:51:04.472 INFO 5080 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
 2016-02-19 14:51:04.506 INFO 5080 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
 2016-02-19 14:51:04.506 INFO 5080 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
 2016-02-19 14:51:04.549 INFO 5080 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
 2016-02-19 14:51:04.720 INFO 5080 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
 2016-02-19 14:51:04.844 INFO 5080 --- [localhost:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:5}] to localhost:27017
 2016-02-19 14:51:04.845 INFO 5080 --- [localhost:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 1]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, roundTripTimeNanos=565904}
 2016-02-19 14:51:05.243 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
 2016-02-19 14:51:05.244 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
 2016-02-19 14:51:05.244 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env || /env.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
 2016-02-19 14:51:05.245 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
 2016-02-19 14:51:05.247 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
 2016-02-19 14:51:05.247 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
 2016-02-19 14:51:05.250 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
 2016-02-19 14:51:05.251 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/health || /health.json],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(java.security.Principal)
 2016-02-19 14:51:05.251 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
 2016-02-19 14:51:05.252 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
 2016-02-19 14:51:05.252 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/info || /info.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
 2016-02-19 14:51:05.253 INFO 5080 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
 2016-02-19 14:51:05.377 INFO 5080 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
 2016-02-19 14:51:05.391 INFO 5080 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
 2016-02-19 14:51:05.561 INFO 5080 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
 2016-02-19 14:51:05.567 INFO 5080 --- [ main] app.Application : Started Application in 5.207 seconds (JVM running for 11.036)
method post
  • 2 2 Answers
  • 134 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    dttutoria Expert
    2022-06-13T12:45:45+00:00Added an answer on June 13, 2022 at 12:45 pm

    The cause: The HTTP response with the 405 Status Code – a client error indicating that the server does not accept the method/verb supplied in the request – is what you’re getting. The cause for this error, as the name implies, is that the request was sent via an unsupported method.

    Solution: You can avoid and correct errors in the following ways:

    • Spring boot shows all available methods on the console as you deploy the application. Check whether the POST method is being presented or not. Make sure there aren’t any inconsistencies with other services. GET/PUT/POST
    • If certain services aren’t available, try putting  ‘/’ before the GET, PUT, or POST commands.
    • Attaching an exception handler to examine the POJO structure based on the client input request.
    • Check the URL to see whether there is a global path for the app/name given in the setup.
    • Remove the headers – Content-Type from the request header and re-submit the request.

    To see if your controller is being considered by the spring application, use the following code:

    import java.util.Arrays;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.ApplicationContext;
    
    @SpringBootApplication
    public class Application {
    
    public static void main(String[] args) {
    ApplicationContext ctx = SpringApplication.run(Application.class, args);
    
    System.out.println("Let's inspect the beans provided by Spring Boot:");
    
    String[] beanNames = ctx.getBeanDefinitionNames();
    Arrays.sort(beanNames);
    for (String beanName : beanNames) {
    System.out.println(beanName);
    }
    }
    
    }
    • 10
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Zoé Boulet
    2022-05-25T20:23:24+00:00Added an answer on May 25, 2022 at 8:23 pm

    If your @SpringBootApplication annotated class and controller are in different packages it does not pick it by default class scan.

    It works in almost all demos because bootstrapping class (@SpringBootApplication annotated class) and rest controller class reside in the same package and loaded to spring context.

    // Make your class available to spring like this

    @SpringBootApplication(scanBasePackageClasses = {GreetingController.class})
    public class BootPocApplication {

    OR // Give the base package name as this

    @SpringBootApplication(scanBasePackages = {"com.tryout"})
    public class BootPocApplication {
    • 4
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.