- import com.itheima.ssm.pojo.Item;
- import com.itheima.ssm.service.ItemService;
- 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 javax.xml.ws.Action;
- @Controller
- @RequestMapping("/item")
- public class ItemController {
- @Autowired
- private ItemService itemService;
- @RequestMapping("showItem/{id}")
- public String findById(@PathVariable("id") int id, Model model){
- Item item = itemService.findById(id);
- model.addAttribute("item",item);
- return "item";
- }
- }
复制代码 |
|