JavaWeb学习-SpringBotWeb开发入门(HTTP协议)
(一)SpringBotWeb开发步骤
(1)创建springboot工程,并勾选开发相关依赖
(2)定义HelloController类,添加方法hello,并添加注解
(3)运行测试
(二)HTTP入门概述
创建请求页面
package com.itheima.demo3; /*请求处理类,加上注解标识为请求处理类*/ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class Conroller { /*指定浏览器处理的请求路径*/ //当浏览器请求/hello时会调用hello()方法 @RequestMapping("/hello") public String hello() { System.out.println("Hello LIUJUNWEI"); return "Hello LJW"; } }
启动类:
package com.itheima.demo3; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /*启动类----启动springBot工程*/ @SpringBootApplication public class Demo3Application { public static void main(String[] args) { SpringApplication.run(Demo3Application.class, args); } }
运行之后在浏览器中输入localhost:8080/hello: