@RestController 下返回网页

@RestController
@RequestMapping("/html")
public class MainController {
    /**
     * 返回网页模板
     *
     * @param model
     * @return
     */
    @RequestMapping("/index")
    public ModelAndView hello(Model model) {
        model.addAttribute("name", "bruce");
        ModelAndView mv = new ModelAndView("index");
        mv.addObject(model);
        return mv;
    }
}

推荐阅读更多精彩内容