如果直接使用springboot的默认的打包成jar包运行,怎么可以返回一个完整的网页呢?
比如:
这样返回的是一个home字符串
@RequestMapping(value = "/",method = RequestMethod.GET)
public String home() {
return "home";
}
这样也是返回字符串:
@ResponseBody
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String test() {
return "很多时候,你还在...";
}
如果我不设置成打包成war包,那么打包成jar形式运行,是如何编辑界面的呢????
需要引入Model
类
...
import org.springframework.ui.Model;
...
@RequestMapping("/")
public String home(Model model) {
return "home";
}
如果执行到return "home";
这部分,spring-boot会自动去src/resource/templates下面找home.html这个文件,这里就可以放置你想要的html内容了
返回一个view的名称或者返回一个ModelAndView
。