【发布时间】:2017-06-21 03:36:41
【问题描述】:
我是 Spring Boot 的初学者。
我刚刚写了一个控制器,代码在这里。
package hello;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@Controller
@EnableAutoConfiguration
public class SampleController {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello Name!";
}
@RequestMapping(value = "/hello/{name}", method = RequestMethod.GET)
String hello(@PathVariable String name) {
return "hello " + name;
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}
然后当我访问“localhost:8080”时,我得到了正确的页面。 但是当我访问“localhost:8080/hello/someName”时,我得到了“Whitelabel Error Page”。
我的代码有什么问题?非常感谢。
【问题讨论】:
标签: java spring spring-boot