1、Idea及Java版本:Idea2019.1 + jdk1.8
2、File > Peoject
3、Spring Initializr:
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://www.f2er.com/idea/526422.html