@Controller注解可以返回一个页面


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;


@Controller
public class IndexController {
@Autowired
private QuestionService questionService;

@GetMapping("/")
public String index(Model model,
@RequestParam(name="page",defaultValue = "1") Integer page,
@RequestParam(name="size",defaultValue = "3") Integer size){

PaginationDTO pagination = questionService.list(page,size);
model.addAttribute("pagination",pagination);

return "index";
}
}
posted @ 2020-12-17 21:38  Mr_sven  阅读(436)  评论(0编辑  收藏  举报