请求方法'POST'不支持,并且亚马逊弹性beantalk - java

尝试在具有Java注释(4.2.1版)的控制器中使用post方法,并在本地tomcat中成功使用,但是当我移至Amazon beantalk时,出现以下错误:

日志:

28-Sep-2015 10:34:11.339 WARNING [http-nio-8080-exec-10] org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Request method 'POST' not supported
28-Sep-2015 10:34:11.340 WARNING [http-nio-8080-exec-10] org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.logException Handler execution resulted in exception: Request method 'POST' not supported
28-Sep-2015 10:34:11.994 WARNING [http-nio-8080-exec-1] org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Request method 'POST' not supported
28-Sep-2015 10:34:11.995 WARNING [http-nio-8080-exec-1] org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.logException Handler execution resulted in exception: Request method 'POST' not supported
28-Sep-2015 10:34:15.915 WARNING [http-nio-8080-exec-9] org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Request method 'POST' not supported
28-Sep-2015 10:34:15.915 WARNING [http-nio-8080-exec-9] org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.logException Handler execution resulted in exception: Request method 'POST' not supported
28-Sep-2015 10:34:16.938 WARNING [http-nio-8080-exec-5] org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Request method 'POST' not supported
28-Sep-2015 10:34:16.938 WARNING [http-nio-8080-exec-5] org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.logException Handler execution resulted in exception: **Request method 'POST' not supported**
28-Sep-2015 10:34:17.660 WARNING [http-nio-8080-exec-10] org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Request method 'POST' not supported 

appConfig.java:

@Configuration
@ComponentScan(basePackages={"service","controller"})
public class AppConfig {

public AppConfig(){

        System.out.println("AppConfig!!!!!!!!!!!!!!!!!!!!!");
    }

    @Autowired
      private ApplicationContext applicationContext;

      /**
       * Actor system singleton for this application.
       */
      @Bean (name="ActorSystem")
      public ActorSystem actorSystem() {
          System.out.println("system issssssssssssssssssssssssss" );
          try {
              ActorSystem system = ActorSystem.create("AkkaJavaSpring");
              System.out.println("system issssssssssssssssssssssssss2222222222" );

                // initialize the application context in the Akka Spring Extension
                SpringExtProvider.get(system).initialize(applicationContext);
                return system;
        } catch (Exception e) {
            System.err.println("ActorSystem initialized exception: " + e);
        }

          System.err.println("no exception!!!!!!!!!!!!!!!!!!!!" );
        return null;
      }

AbstractAnnotationConfigDispatcherServletInitializer:

public class DispatcherServletInitializer  extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        System.out.println("getRootConfigClasses!!!!!!!!!!!!!! succed");
        return new Class<?>[] {
            WebConfig.class,
            AppConfig.class
        };
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return null;
    }

    @Override
    protected String[] getServletMappings() {
        return new String[] { "/" };
    }

    @Override
    protected Filter[] getServletFilters() {
        System.out.println("filter !!!!!!!!!!!!!! succed");
        return new Filter[] { new HiddenHttpMethodFilter() };
    }

}

webConfig:

@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter{

    @Override
      public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {

//      configurer.ignoreAcceptHeader(true).defaultContentType(
//              MediaType.APPLICATION_JSON);

        configurer.favorPathExtension(false).
                favorParameter(true).
                parameterName("mediaType").
                ignoreAcceptHeader(true).
                useJaf(false).
                defaultContentType(MediaType.APPLICATION_JSON).
                mediaType("xml", MediaType.APPLICATION_XML).
                mediaType("json", MediaType.APPLICATION_JSON);

      }

    @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/**").addResourceLocations("/");

      }

控制器:

@RestController
@RequestMapping(value="/api/mail")
public class SendMailController {


    //Dispatcher dispatcher; 

    //@Autowired
    public SendMailController(){
        //this.dispatcher = dispatcher;
        System.out.println("SendMailController has been loaded!!!!!!!!!!!!!!!!!!!!!");
    }



    @RequestMapping(produces = "application/json" ,method=RequestMethod.POST )

    public ResponseEntity<HttpStatus> sendMail(@RequestBody MailRequest mailRequest){

        System.out.println("MailRequest 2 mailRequest!!!!!!!!!!!!!!!!!!! " );

    //  dispatcher.SendMail(new MailRequestEvent(mailRequest));
        return new ResponseEntity<HttpStatus>(HttpStatus.OK);
    }

}

请我在这里需要帮助

参考方案

问题是在我的URL中,tomcat的URL与URL之间存在差异
为了使发送者具有弹性,要使您具有弹性,您不必在URL中包含项目名称,而在tomcat中,您必须包含项目名称

谢谢

Java-如何将此字符串转换为日期? - java

我从服务器收到此消息,我不明白T和Z的含义,2012-08-24T09:59:59Z将此字符串转换为Date对象的正确SimpleDateFormat模式是什么? java大神给出的解决方案 这是ISO 8601标准。您可以使用SimpleDateFormat simpleFormat = new SimpleDateFormat("yyyy-MM…

将列表的python排序转换为Java代码。 - java

我正在尝试将将items列表排序为Java代码的python代码进行转换。如何在Java中进行这种排序?python code:import re items = ['10H', '10S', '2H', '3S', '4S', '6C',…

如何避免用户输入中的撇号 - java

因此,我正在将信息从.csv文件导入数据库。但是我在csv文件中用户输入的描述遇到了麻烦,因为它们包含的单引号破坏了SQL导入。我的导入语句是字符串sqlJob ="INSERT INTO job (ID, Job_Contact, Internal_Comment, Customer_Name," + " Duration, …

为什么`if(guess!='a'|| guess!='A'||…)`不起作用? - java

Improve this question 这是我的代码,我知道if语句真的很长,代码可能会更高效,但是我只是想知道答案,因为它使我发疯。while (whileloop == 1) { if (guess != 'a' || guess != 'A' || guess != 'b' || gues…

如何从php中获取datatables jQuery插件的json数据 - php

我是PHP的新手,正在尝试使用Datatables jQuery插件。我知道我必须从.php文件中获取数据,然后在数据表中使用它,但是我似乎无法通过ajax将其传递给数据表。我设法从数据库中获取数据,并对其进行json编码,但是后来我不知道如何在我的index.php文件中调用它,并在其中显示它。我究竟做错了什么?这是我的代码:HTML(已编辑): <…