Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.github.bysrhq.todoapp.controller; import com.github.bysrhq.todoapp.repository.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; /** * * @author bysrhq */ @Controller @RequestMapping("/user") public class UserController { @Autowired private UserRepository userRepository; @GetMapping("/{username}") public ModelAndView showUserPage(@PathVariable String username) { return new ModelAndView("userPage", "user", userRepository.findOne(username)); } }