Answer the question
In order to leave comments, you need to log in
SpringMVC: what should be the project structure?
Hello, I have a week of experience with SpringMVC + Mybatis
At the moment my project structure is as follows:
I am looking for information about what should be the structure of a Spring project.
Connecting content, all kinds of blocks, pagination will make the controller redundant
@Controller
public class Index {
@Autowired
private UserService userService;
@Autowired
private ItemsService itemsService;
private final int LIMIT_ITEMS = 15;
@RequestMapping(value = {"/", "/{modifier:new|best}"}, method = RequestMethod.GET)
public ModelAndView index(@PathVariable Optional<String> modifier,
@RequestParam(required = false, defaultValue = "1") Integer page,
HttpServletRequest request, ModelAndView mv) throws URISyntaxException {
Pagination pagination = new Pagination(page, LIMIT_ITEMS, Utils.getURI(request));
mv.addObject("items", itemsService.selectItems(modifier, page, LIMIT_ITEMS));
pagination.setCountItems(itemsService.countItems());
pagination.initPagination();
mv.addObject("pagination", pagination);
mv.addObject("page", "index");
mv.setViewName("template-1");
return mv;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question