1、建立项目

Java Controller

 1 package com.springboot.jsp.controller;
 2 
 3 import org.springframework.stereotype.Controller;
 4 import org.springframework.ui.Model;
 5 import org.springframework.web.bind.annotation.RequestMapping;
 6 import org.springframework.web.bind.annotation.ResponseBody;
 7 
 8 import java.util.HashMap;
 9 import java.util.Map;
10 
11 /******************************
12  * @author : liuyang
13  * <p>ProjectName:12-jsp  </p>
14  * @ClassName :  MyController
15  * @date : 2018/7/27 0027
16  * @time : 21:48
17  * @createTime 2018-07-27 21:48
18  * @version : 2.0
19  * @description :
20  *
21  *
22  *
23  *******************************/
24 
25 @Controller
26 public class MyController {
27 
28 
29     @RequestMapping("/boot/json")
30     public @ResponseBody
31     Object json() {
32 
33         Map<String, Object> map = new HashMap<>();
34         map.put("name", "张三");
35         map.put("age", "12");
36         return map;
37 
38     }
39 
40 
41     @RequestMapping("/my/index")
42     public String index(Model model) {
43         model.addAttribute("say", "去你妈的");
44         return "index";
45     }
46 }
View Code

相关文章: