上一遍文章我们讲了如何搭建个Spring Boot程序,今天来讲下如何从后台把数据传到前面
浏览器输入http://localhost:5678/ 效果如下
代码如下
package com.example.demo;
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 {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@RequestMapping(value = "/",produces = "text/plain;charset=UTF-8")
String index(){
return "Hello Spring Boot!";
}
}