1、Idea及Java版本:Idea2019.1 + jdk1.8
2、File > Peoject
3、Spring Initializr:
4、之后会自动下载需要的相关文件
5、src > main > com.xxx.xxx下创建HelloController,内容如下:
package com
.weihua
.xxx
;
import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
import org
.springframework
.web
.bind
.annotation
.RestController
;
@RestController
public class HelloController {
@
RequestMapping(value
= "/hello", method
= RequestMethod
.GET)
public String
helloWorld () {
return "Hello World !";
}
}
6、运行XxxApplication,在浏览器窗口输入http://localhost:8080/hello,页面显示:Hello World !
7、src > main > resources > static下存放静态资源文件如html、js、css等。
转载请注明原文地址: https://yun.8miu.com/read-134422.html