【问题标题】:Spring Boot 1.5.9 context-path HEAD response not workingSpring Boot 1.5.9 上下文路径 HEAD 响应不起作用
【发布时间】:2018-07-04 10:08:06
【问题描述】:

我在 Spring Boor 中从 RestController 设置 HEAD 响应时遇到问题。我目前使用的是 Spring Boot 1.5.9 版。

我已经设置了新项目来演示这个问题。在 application.properties 我只有一行:

server.context-path=/api/v1

我的 RestController "TestController.java"

@RestController
public class TestController {

    @GetMapping("/test")
    public String test() {
        return "test";
    }
}

当我尝试在 url http://localhost:8080/api/v1/test 上仅获取带有 HTTP HEAD 请求的标头时,响应堆栈并且我没有得到任何响应。在应用程序控制台中没有错误。

如果我从 application.properties 中删除 server.context-path=/api/v1。然后对http://localhost:8080/test 的 HEAD 请求按预期工作。

感谢您的帮助, 马丁

【问题讨论】:

  • 这里似乎没有错。你能分享你的 pom 文件吗?
  • 我忽略了你的反应。我正在使用 gradle。

标签: spring-boot head contextpath


【解决方案1】:

这里是 build.gradle

buildscript {
    ext {
        springBootVersion = '1.5.9.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-websocket')
//    compile('com.microsoft.sqlserver:sqljdbc4')
    runtime('org.springframework.boot:spring-boot-devtools')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

【讨论】:

    猜你喜欢
    • 2019-10-30
    • 1970-01-01
    • 2017-03-03
    • 2019-08-22
    • 1970-01-01
    • 2021-02-17
    • 2018-05-06
    • 1970-01-01
    • 2018-08-17
    相关资源
    最近更新 更多