- 首先添加springmvc 的依赖
compile('org.springframework.boot:spring-boot-starter-web')//springmvc/
-
新建controller类,并在类名上添加@RestController注解
-
在方法名上添加@RequestMapping("/")注解,括号中的为url路径,代表此方法的URL为localhost:8080/
然后build项目,在cmd中进入build/libs/中执行 java -jar xxxxx.jar
- 最后在浏览器中打开localhost:8080/,既可以看到helloworld啊啊啊了,到这里springmvc引入成功,我们将在其他文章中详细介绍springmvc的配置