zoukankan      html  css  js  c++  java
  • springmvc框架开发常用的注解总结

    复制代码
    1    //使用RESTful风格传送参数
    2     @RequestMapping("/item/{itemId}")
    3     @ResponseBody     //该注解是将返回的对象转成json格式的数据响应
    4     //注解@PathVariable表示接受占位符传递过来的值
    5     public TbItem queryItemById(@PathVariable Long itemId){
    6         return itemService.queryItemById(itemId);
    7     }
    复制代码
    6、@RequestParam的使用:
      第一种方式:@RequestParam(defaultValue="1")表示设置controller方法上形参的默认值,通常用于在分页时设置当前页数的默认值为1,因为页面第一次访问时当前页数page变量的值null。

    复制代码
     1     /**
     2      * 分页查询广告内容表中的数据:
     3      * @param page:当前页数
     4      * @param rows:每页显示的记录数
     5      * @param categoryId:默认展示内容类目为0的记录
     6      * @return
     7      */
     8     @RequestMapping("/query/list")
     9     @ResponseBody
    10     //@RequestParam(defaultValue="1")表示默认当前页数为第一页
    11     public DatagridResult queryContentList(@RequestParam(defaultValue="1") Integer page,Integer rows,Long categoryId){
    12         
    13         return contentService.queryContentList(page, rows, categoryId);
    14     }
    复制代码
      第二种方式:@RequestParam(value="id",defaultValue="0")表示设置controller方法上形参变量的值是通过value属性的变量(id)赋值的,通过defaultValue属性设置默认值。
  • 相关阅读:
    Bluedroid介绍
    Android蓝牙介绍
    Android Bluetooth抓包
    Bluetooth LMP介绍
    Bluetooth Baseband介绍
    Bluetooth SDP介绍
    Bluetooth HFP介绍
    Bluetooth RFCOMM介绍
    Bluetooth L2CAP介绍
    Windows开发
  • 原文地址:https://www.cnblogs.com/wangchaoyuana/p/7545268.html
Copyright © 2011-2022 走看看