@RequestMapping的简单理解

@Controller
public class ItemController {
    @Autowired
    private ItemService itemService;
    获取路径参数.../item/*
    @RequestMapping("/item/{itemId}")
    @ResponseBody
//    HTTP Status 404 - /WEB-INF/jsp/item/536563.jsp
//    和晶晶的正相反,应该是导入数据库的问题
//    出现了manager的pom.xml文件忘记添加依赖common了
//此版本还删除了common中的一些包com.taotao.common,在commom的java包下,晶晶版保留
//    @PathVariable是从路径中取参数
    public TbItem getItemById(@PathVariable Long itemId) {
        TbItem tbItem = itemService.geTbItemById(itemId);
        return tbItem;
    }
}
    /**
     * 通常为首页/ */
    @RequestMapping("/")
    public String showIndex() {
        return "index";
    }
    /**
     * 只要下面haha删除对应位置自定义名称一致就行,随便命名
     * @param page
     * @return
     */
    @RequestMapping("/{haha}")
    public String showpage(@PathVariable String haha) {
        return haha;
    }
相关文章
相关标签/搜索