时间:2021-07-01 10:21:17 帮助过:734人阅读
有了以上这两步就没问题了,如下是项目的目录结构
Spring 启动类及MVC的 控制器部分代码:
package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.example.bean.User; @Controller @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); System.out.print("app init"); } @RequestMapping("/hello") @ResponseBody String home() { System.out.print("hello"); return "Hello ,spring boot!"; } @RequestMapping("/") public String index() { System.out.print("index"); return "index"; } @RequestMapping("/userLogin") public String userLogin(Model model) { User user = new User("guozhong",30); model.addAttribute("user",user); return "userLogin"; } }View Code
浏览器访问:
template might not exist or might not be accessible by any of the configured Template Resolvers 完美解决
标签:click app event resolve mode spring dem display 项目