问题:
使用Spring 4,我在访问网页时得到了这个
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Aug 15 16:41:29 BST 2014
There was an unexpected error (type=Not Found, status=404).
我有的:
我有这个主班:
// src/main/java/abc/Main.java
package abc;
import abc.web.WebAppConfig;
import org.springframework.boot.SpringApplication;
public class Main {
public static void main(String[] args) {
SpringApplication.run(WebAppConfig.class);
}
}
然后,我有了这个WebAppConfig.class(当前仅带有一些配置注释):
// src/main/java/abc/web/WebAppConfig.java
package abc.web;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan
@EnableAutoConfiguration
public class WebAppConfig {
}
而这个控制器HomeController.java:
// src/main/java/abc/web/HomeController.java
package abc.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
@Controller
@RequestMapping("/")
public class HomeController {
@RequestMapping(method = GET)
public String home() {
System.out.println("HELLO !!");
return "home";
}
}
喂!显示在日志中。
最后我有一个html文件src/main/java/abc/webapp/home.html,其中只有一些html标记,包括带有的p标记Hello,
world!。
问题:
我知道我缺少渲染视图的方法,但是我搜索了一些关于stackoverflow的问题,但还没有找到解决方案。
有人可以解释一下如何让Spring呈现网页吗?我想念什么?
提前致谢 :)