(1)application.properties
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.cache=false
spring.thymeleaf.content-type=text/html
spring.thymeleaf.enabled=true
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.mode=HTML5
(2)controller
@Controller("user_controller")
@RequestMapping("/user")
public class UserController{
@Autowired
@Qualifier("userService") /* 一个接口多个实现用name区分*/
private IUserService userService;
@RequestMapping("/")
public String list(Model model) {
System.out.println(" *** controller *** "+this);
List
model.addAttribute("userList", list);
return "users/list";
}
@RequestMapping("/delete/{id}")
public String delete(@PathVariable("id") String id){
userService.deleteUser(id);
return "redirect:/user/";
}
@RequestMapping(value="/save", method=RequestMethod.POST)
//public String save(@RequestBody UserVO user){ //415错误
public String save() {
return "forward:/user/";
}
@RequestMapping("/{id}")
public String get(@PathVariable String id, Model model){
if("toadd".equals(id)) {
return toAddPage();
}
System.out.println(" *** controller *** "+this);
UserVO user = userService.findUserByID(id);
model.addAttribute("user", user);
// return "forward:/";
return "users/detail";
}
public String toAddPage(){
return "users/add";
}
}
(3)页面
android入门实例:https://gitbook.cn/gitchat/activity/5d382e64b669c0566c335b32