【发布时间】:2017-02-18 20:36:27
【问题描述】:
我是 Spring Boot 新手。任何时候我运行我的 Spring Boot 应用程序时,都会出错。 在运行我的 Spring Boot 应用程序时需要帮助。
错误信息: 白标错误页面
此应用程序没有显式映射 /error,因此您将其视为后备。
2016 年 10 月 10 日星期一 10:39:54 WAT 出现意外错误(类型=未找到,状态=404)。 没有可用的消息
代码:
package hello;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GreetingController {
@RequestMapping("/greeting")
public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
model.addAttribute("name", name);
return "greeting";
}
}
package com.HelloWorld;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class HelloWorldApplication {
public static void main(String[] args) {
SpringApplication.run(HelloWorldApplication.class, args);
}
}
- greeting.html
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'Hello, ' + ${name} + '!'" />
</body>
</html>
【问题讨论】:
-
您要访问哪个网址?
标签: java spring spring-mvc spring-boot