spring-boot之helloWorld

You need to add a class, then write a method, annotate using RestController

@RestController

public class HelloWorld {

@RequestMapping("/")

public String sayHelloWorld(){

return "hello world!";

}

}

Then start it through the class run in springApplicationMain

Then the browser accesses: http://127.0.0.1:8081/ and you can see hello world

Explain that the role of the RestController annotation is to return data in json format

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326877320&siteId=291194637