请求方法“ HEAD”不支持

bizzr3

我使用apache tomcat 7.0.55运行了一个Intellij Idea的新实例,并且创建了一个新的简单项目,但是我不断遇到此错误:

Feb 28, 2015 11:54:13 PM org.springframework.web.servlet.PageNotFound handleHttpRequestMethodNotSupported
WARNING: Request method 'HEAD' not supported

控制器:

package com.springapp.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping(value="/",method = {RequestMethod.GET, RequestMethod.HEAD})
public class HelloController {
    @RequestMapping(method = RequestMethod.GET)
    public String printWelcome(ModelMap model) {
        model.addAttribute("message", "Hello world!");
        return "hello";
    }
}

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.springapp</groupId>
    <artifactId>untitled</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>untitled</name>

    <properties>
        <spring.version>4.1.1.RELEASE</spring.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>untitled</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>**/*Tests.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
Serge Ballesta

在课堂上,

@RequestMapping(value="/",method = {RequestMethod.GET, RequestMethod.HEAD})
public class HelloController {

您声明控制器将处理GETHEAD请求root URL /

但是在方法层面上

@RequestMapping(method = RequestMethod.GET)

您只接受GET请求。春天是正确的,请求方法“HEAD”不支持的

您应该在方法级别(@RequestMapping(value = "")接受所有内容,或者创建第二种方法来处理HEAD请求。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

春季警告:不支持请求方法“ HEAD”

来自分类Dev

支持的方法:GET,HEAD,但不支持POST

来自分类Dev

Swagger UI 显示 API 不支持的 HTTP HEAD 方法

来自分类Dev

春季:请求方法'POST'不支持

来自分类Dev

HttpRequestMethodNotSupportedException:不支持请求方法“ POST”

来自分类Dev

错误:请求方法'GET'不支持

来自分类Dev

不支持 Springboot 请求方法“POST”

来自分类Dev

该路由不支持POST方法。支持的方法:GET,HEAD

来自分类Dev

Laravel API:此路由不支持POST方法。支持的方法:GET,HEAD

来自分类Dev

该路由不支持POST方法。支持的方法:GET,HEAD(LARAVEL)

来自分类Dev

该路由不支持POST方法。支持的方法:GET,HEAD,PUT

来自分类Dev

该路由不支持POST方法。支持的方法:GET,HEAD。在laravel api中

来自分类Dev

“此路由不支持POST方法。受支持的方法:GET,HEAD

来自分类Dev

错误:此路由不支持POST方法。支持的方法:GET,HEAD

来自分类Dev

该路由不支持POST方法。支持的方法:GET,HEAD。”

来自分类Dev

如何修复“此路由不支持 POST 方法。支持的方法:GET、HEAD.'?

来自分类Dev

使用Spring Security登录:请求方法'POST'不支持

来自分类Dev

Spring MVC-不支持请求方法“ POST”

来自分类Dev

请求的资源不支持HTTP方法GET

来自分类Dev

为什么我不支持请求方法GET?

来自分类Dev

方法不支持请求正文:GET / POST

来自分类Dev

请求方法'GET'不支持Spring MVC

来自分类Dev

STS不支持请求的身份验证方法

来自分类Dev

SpringMVC 3.2.4请求方法'PUT'不支持

来自分类Dev

Spring Security 4:不支持请求方法“ POST”

来自分类Dev

Spring Boot Rest服务| 请求方法'GET'不支持

来自分类Dev

Spring Security不支持请求方法“ POST”

来自分类Dev

HTTP状态405-不支持请求方法“ PUT”

来自分类Dev

Spring正常关机-不支持请求方法过帐

Related 相关文章

  1. 1

    春季警告:不支持请求方法“ HEAD”

  2. 2

    支持的方法:GET,HEAD,但不支持POST

  3. 3

    Swagger UI 显示 API 不支持的 HTTP HEAD 方法

  4. 4

    春季:请求方法'POST'不支持

  5. 5

    HttpRequestMethodNotSupportedException:不支持请求方法“ POST”

  6. 6

    错误:请求方法'GET'不支持

  7. 7

    不支持 Springboot 请求方法“POST”

  8. 8

    该路由不支持POST方法。支持的方法:GET,HEAD

  9. 9

    Laravel API:此路由不支持POST方法。支持的方法:GET,HEAD

  10. 10

    该路由不支持POST方法。支持的方法:GET,HEAD(LARAVEL)

  11. 11

    该路由不支持POST方法。支持的方法:GET,HEAD,PUT

  12. 12

    该路由不支持POST方法。支持的方法:GET,HEAD。在laravel api中

  13. 13

    “此路由不支持POST方法。受支持的方法:GET,HEAD

  14. 14

    错误:此路由不支持POST方法。支持的方法:GET,HEAD

  15. 15

    该路由不支持POST方法。支持的方法:GET,HEAD。”

  16. 16

    如何修复“此路由不支持 POST 方法。支持的方法:GET、HEAD.'?

  17. 17

    使用Spring Security登录:请求方法'POST'不支持

  18. 18

    Spring MVC-不支持请求方法“ POST”

  19. 19

    请求的资源不支持HTTP方法GET

  20. 20

    为什么我不支持请求方法GET?

  21. 21

    方法不支持请求正文:GET / POST

  22. 22

    请求方法'GET'不支持Spring MVC

  23. 23

    STS不支持请求的身份验证方法

  24. 24

    SpringMVC 3.2.4请求方法'PUT'不支持

  25. 25

    Spring Security 4:不支持请求方法“ POST”

  26. 26

    Spring Boot Rest服务| 请求方法'GET'不支持

  27. 27

    Spring Security不支持请求方法“ POST”

  28. 28

    HTTP状态405-不支持请求方法“ PUT”

  29. 29

    Spring正常关机-不支持请求方法过帐

热门标签

归档