0

问题: 为什么我会收到白标错误页面?

确切的错误:

白标错误页面

此应用程序没有显式映射 /error,因此您将其视为后备。

Thu Sep 17 12:11:02 CDT 2015
    There was an unexpected error (type=Not Found, status=404).
    No message available

背景: 我正在按照 spring.io 入门指南使用 spring 构建 RESTful Web 服务。

https://spring.io/guides/gs/rest-service/#scratch

我正在使用 Spring 工具套件,并按照教程进行操作。

我的代码:

问候语.java

package hello;

public class Greeting {

    private final long id;
    private final String content;

    public Greeting(long id, String content){
        this.id = id;
        this.content = content;
    }

    public long getId() {
        return id;
    }

    public String getContent() {
        return content;
    }
}

GreetingController.java

package hello;

import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestParam;

@RestController
public class GreetingController {

    private final String template = "Hello, %s!";
    private final AtomicLong counter = new AtomicLong();


    @RequestMapping("/greeter")
    public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
        return new Greeting( counter.incrementAndGet(), String.format(template, name));
    }

}

应用程序.java

package hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {        
        SpringApplication.run(Application.class, args);     
    }

}
4

0 回答 0