controller中的代码如下:问题  返回值类型为@RestController时,直接转换为了json字符串,就无法返回thymeleaf页面,改为@Controller即可

@RestController
@RequestMapping("user")
public class UserController {

@Autowired
private UserService userService;

@GetMapping("all")
public String all(Model model) {
// 查询用户
List<User> users = this.userService.queryAll();
// 放入模型
model.addAttribute("users", users);
// 返回模板名称(就是classpath:/templates/目录下的html文件名)
return "users";

}
}

相关文章:

  • 2022-01-05
  • 2021-10-03
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-06-26
  • 2021-08-21
  • 2022-01-25
  • 2022-12-23
相关资源
相似解决方案