zoukankan      html  css  js  c++  java
  • 使用@RequestParam绑定请求参数到方法参数

    @RequestParam注解用于在控制器中绑定请求参数到方法参数.
    用法如下:
    @RequestMapping
     public void advancedSearch(
       @RequestParam("queryStr") String queryStr,
       @RequestParam("showFlag") String showFlag,
       @RequestParam("totalnumber") String totalNumber,
       @RequestParam("upType") String upType,
       @RequestParam("jmesareq") String jmesaReq,
       @RequestParam("isExportOper") String isExportOper,
       HttpServletResponse response, final HttpServletRequest request,
       ModelMap model) {
      // get query structure and query type from page
      List<Long> cd_ids = new ArrayList<Long>();
      if(StringUtils.equals("invoke", jmesaReq)){
       cd_ids = (List<Long>)request.getSession().getAttribute(Constants.RESULT_IDS);
      }
     ....
     }

    使用这个注解参数默认是必需的, 但是可以把@RequestParam的required属性设置为false从而让这个参数可选.
    例如@RequestParam(value="name", required="false")

  • 相关阅读:
    函数中this指向问题及函数不同方式的调用
    拷贝继承
    组合继承
    借用构造函数
    继承
    UVA-11054(扫描法)
    hihocoder-1347 小h的树上的朋友(lca+线段树)
    UVA-10391(字符串检索)
    UVA-10125(中途相遇法)
    UVA-10827(前缀和降维)
  • 原文地址:https://www.cnblogs.com/toSeeMyDream/p/4487015.html
Copyright © 2011-2022 走看看