想实现输入http://localhost:8080/sayhello?name=自己名字,然后在网页上跳出名字
我的project:
运行DemoApplication时候报错还有一个warning:
DemoApplication:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class DemoApplication {
@RequestMapping("/hello")
public String first(){
return "hello!Stephen!";
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
另外DemoApplication默认情况下也报错: