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.ecto.engine.controllers; import com.ecto.engine.entity.Article; import com.ecto.engine.service.ArticleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller public class ArticleController { @Autowired private ArticleService articleService; @RequestMapping(value = "/article/{a}", method = RequestMethod.GET) public String getArticle(@PathVariable Integer a, Model model) { Article article = articleService.findById(a); model.addAttribute("article", article); return "article"; } }