M
M
Mark Ivanych2016-01-24 12:59:49
Java
Mark Ivanych, 2016-01-24 12:59:49

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:
6e1614faf7be41ce8f5b94196f233fa0.jpg
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;
    }
}

Tell me how you are doing or a link to a project that a beginner can figure out.
I managed to find it myself:
https://github.com/spring-io/sagan - too complicated and a lot of things
https://github.com/spring-projects/spring-boot - just examples

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question