forked from leechenxiang/imooc-springboot-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8639697
commit 5772071
Showing
13 changed files
with
523 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 27 additions & 27 deletions
54
src/main/java/com/imooc/controller/FreemarkerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
package com.imooc.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.ModelMap; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import com.imooc.pojo.Resource; | ||
|
||
@Controller | ||
@RequestMapping("ftl") | ||
public class FreemarkerController { | ||
|
||
@Autowired | ||
private Resource resource; | ||
|
||
@RequestMapping("/index") | ||
public String index(ModelMap map) { | ||
map.addAttribute("resource", resource); | ||
return "freemarker/index"; | ||
} | ||
|
||
@RequestMapping("center") | ||
public String center() { | ||
return "freemarker/center/center"; | ||
} | ||
|
||
package com.imooc.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.ModelMap; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import com.imooc.pojo.Resource; | ||
|
||
@Controller | ||
@RequestMapping("ftl") | ||
public class FreemarkerController { | ||
|
||
@Autowired | ||
private Resource resource; | ||
|
||
@RequestMapping("/index") | ||
public String index(ModelMap map) { | ||
map.addAttribute("resource", resource); | ||
return "freemarker/index"; | ||
} | ||
|
||
@RequestMapping("center") | ||
public String center() { | ||
return "freemarker/center/center"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
package com.imooc.controller; | ||
|
||
import org.springframework.beans.BeanUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.imooc.pojo.IMoocJSONResult; | ||
import com.imooc.pojo.Resource; | ||
|
||
@RestController | ||
public class HelloContoller { | ||
|
||
@Autowired | ||
private Resource resource; | ||
|
||
@RequestMapping("/hello") | ||
public Object hello() { | ||
return "hello springboot~~"; | ||
} | ||
|
||
@RequestMapping("/getResource") | ||
public IMoocJSONResult getResource() { | ||
|
||
Resource bean = new Resource(); | ||
BeanUtils.copyProperties(resource, bean); | ||
|
||
return IMoocJSONResult.ok(bean); | ||
} | ||
|
||
} | ||
package com.imooc.controller; | ||
|
||
import org.springframework.beans.BeanUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.imooc.pojo.IMoocJSONResult; | ||
import com.imooc.pojo.Resource; | ||
|
||
@RestController | ||
public class HelloContoller { | ||
|
||
@Autowired | ||
private Resource resource; | ||
|
||
@RequestMapping("/hello") | ||
public Object hello() { | ||
return "hello springboot~~"; | ||
} | ||
|
||
@RequestMapping("/getResource") | ||
public IMoocJSONResult getResource() { | ||
|
||
Resource bean = new Resource(); | ||
BeanUtils.copyProperties(resource, bean); | ||
|
||
return IMoocJSONResult.ok(bean); | ||
} | ||
|
||
} |
156 changes: 78 additions & 78 deletions
156
src/main/java/com/imooc/controller/ThymeleafController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,79 @@ | ||
package com.imooc.controller; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.ModelMap; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import com.imooc.pojo.User; | ||
|
||
@Controller | ||
@RequestMapping("th") | ||
public class ThymeleafController { | ||
|
||
@RequestMapping("/index") | ||
public String index(ModelMap map) { | ||
map.addAttribute("name", "thymeleaf-imooc"); | ||
return "thymeleaf/index"; | ||
} | ||
|
||
@RequestMapping("center") | ||
public String center() { | ||
return "thymeleaf/center/center"; | ||
} | ||
|
||
@RequestMapping("test") | ||
public String test(ModelMap map) { | ||
|
||
User u = new User(); | ||
u.setName("superadmin"); | ||
u.setAge(10); | ||
u.setPassword("123465"); | ||
u.setBirthday(new Date()); | ||
u.setDesc("<font color='green'><b>hello imooc</b></font>"); | ||
|
||
map.addAttribute("user", u); | ||
|
||
User u1 = new User(); | ||
u1.setAge(19); | ||
u1.setName("imooc"); | ||
u1.setPassword("123456"); | ||
u1.setBirthday(new Date()); | ||
|
||
User u2 = new User(); | ||
u2.setAge(17); | ||
u2.setName("LeeCX"); | ||
u2.setPassword("123456"); | ||
u2.setBirthday(new Date()); | ||
|
||
List<User> userList = new ArrayList<>(); | ||
userList.add(u); | ||
userList.add(u1); | ||
userList.add(u2); | ||
|
||
map.addAttribute("userList", userList); | ||
|
||
return "thymeleaf/test"; | ||
} | ||
|
||
@PostMapping("postform") | ||
public String postform(User u) { | ||
|
||
System.out.println("姓名:" + u.getName()); | ||
System.out.println("年龄:" + u.getAge()); | ||
|
||
return "redirect:/th/test"; | ||
} | ||
|
||
@RequestMapping("showerror") | ||
public String showerror(User u) { | ||
|
||
int a = 1 / 0; | ||
|
||
return "redirect:/th/test"; | ||
} | ||
package com.imooc.controller; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.ModelMap; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import com.imooc.pojo.User; | ||
|
||
@Controller | ||
@RequestMapping("th") | ||
public class ThymeleafController { | ||
|
||
@RequestMapping("/index") | ||
public String index(ModelMap map) { | ||
map.addAttribute("name", "thymeleaf-imooc"); | ||
return "thymeleaf/index"; | ||
} | ||
|
||
@RequestMapping("center") | ||
public String center() { | ||
return "thymeleaf/center/center"; | ||
} | ||
|
||
@RequestMapping("test") | ||
public String test(ModelMap map) { | ||
|
||
User u = new User(); | ||
u.setName("superadmin"); | ||
u.setAge(10); | ||
u.setPassword("123465"); | ||
u.setBirthday(new Date()); | ||
u.setDesc("<font color='green'><b>hello imooc</b></font>"); | ||
|
||
map.addAttribute("user", u); | ||
|
||
User u1 = new User(); | ||
u1.setAge(19); | ||
u1.setName("imooc"); | ||
u1.setPassword("123456"); | ||
u1.setBirthday(new Date()); | ||
|
||
User u2 = new User(); | ||
u2.setAge(17); | ||
u2.setName("LeeCX"); | ||
u2.setPassword("123456"); | ||
u2.setBirthday(new Date()); | ||
|
||
List<User> userList = new ArrayList<>(); | ||
userList.add(u); | ||
userList.add(u1); | ||
userList.add(u2); | ||
|
||
map.addAttribute("userList", userList); | ||
|
||
return "thymeleaf/test"; | ||
} | ||
|
||
@PostMapping("postform") | ||
public String postform(User u) { | ||
|
||
System.out.println("姓名:" + u.getName()); | ||
System.out.println("年龄:" + u.getAge()); | ||
|
||
return "redirect:/th/test"; | ||
} | ||
|
||
@RequestMapping("showerror") | ||
public String showerror(User u) { | ||
|
||
int a = 1 / 0; | ||
|
||
return "redirect:/th/test"; | ||
} | ||
} |
Oops, something went wrong.