使用Thymeleaf模板引擎渲染web视图
This commit is contained in:
57
Chapter3-1-2/src/main/java/com/didispace/web/HelloController.java
Executable file → Normal file
57
Chapter3-1-2/src/main/java/com/didispace/web/HelloController.java
Executable file → Normal file
@@ -1,29 +1,30 @@
|
||||
package com.didispace.web;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 程序猿DD
|
||||
* @version 1.0.0
|
||||
* @blog http://blog.didispace.com
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class HelloController {
|
||||
|
||||
@RequestMapping("/hello")
|
||||
public String hello() {
|
||||
return "Hello World";
|
||||
}
|
||||
|
||||
@RequestMapping("/")
|
||||
public String index(ModelMap map) {
|
||||
map.addAttribute("host", "http://blog.didispace.com");
|
||||
return "index";
|
||||
}
|
||||
|
||||
package com.didispace.web;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 程序猿DD
|
||||
* @version 1.0.0
|
||||
* @blog http://blog.didispace.com
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class HelloController {
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/hello")
|
||||
public String hello() {
|
||||
return "Hello World";
|
||||
}
|
||||
|
||||
@RequestMapping("/")
|
||||
public String index(ModelMap map) {
|
||||
map.addAttribute("host", "http://blog.didispace.com");
|
||||
return "index";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user