发表于: 2017-10-06 18:19:08
1 803
今天完成的任务
在@RequestMapping标签里,直接写定义此标签的地址或者在此基础上通过定义该方法使用的模式都是可以的
RequestMethod.GET,RequestMethod.POST
这就是REST风格的写法吗.
然后参考了姚远师兄8月23日的周报
// 告诉spring mvc这是一个控制器类
@Controller
@RequestMapping(value = "",method = RequestMethod.GET)
class CategoryController {
@Autowired
CategoryService categoryService;
int id=2;
@RequestMapping(value ="/listCategory/{id}", method = RequestMethod.GET)
public ModelAndView listCategory(@PathVariable int id, Page page){
ModelAndView mav = new ModelAndView();
List<Category> cs= categoryService.list(page);
mav.addObject("cs", cs);
mav.setViewName("listCategory");
return mav;
}
}
运行以后
发现在http://localhost/listCategory/1?start=0中无论id的值为多少,都可以成功打开页面
看了一下postman,明天下载一下试试
遇到的问题
收获
评论