zoukankan      html  css  js  c++  java
  • @PathVariable注解的使用和@Requestparam

    一、 @PathVariable

     @PathVariable这是一个路径映射格式的书写方式注解,在类映射路径的后加上/{对应方法参数中属性@PathVariable("code")中的code},

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @RequestMapping(value = "/decodeUserInfo/{codee}", method = RequestMethod.GET)
    @ResponseBody
    public Map decodeUserInfo(@PathVariable("codee") String codee) {

    Map map = new HashMap();

    /////////////////////////////////////////////////////////////////////////自己定义的code

    String code = codee;

     

     二、@Requestparam注解将请求参数绑定至方法参数即你可以使用@RequestParam注解将请求参数绑定到你控制器的方法参数上

    1.value:请求参数名(必须配置)

    2.required:是否必须,默认true,即请求中必须包含该参数,如果没有包含,将会抛出异常(可选配置)

    3.defaultValue:默认值,如果设置了该值,require将自动设为false,无论你是否配置了required,配置了什么值,required将自动设为false

    @Requestparam(value="表示参数名字",require=boolean类型表示是否为必须,defaultValue=“表示默认值”)

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @RequestMapping(value = "/decodeUserInfo", method = RequestMethod.GET)
    @ResponseBody
    public Map decodeUserInfo(@RequestParam String codee) {

    Map map = new HashMap();

    /////////////////////////////////////////////////////////////////////////自己定义的code

    String code = codee;

    
    
    
  • 相关阅读:
    Linux系统:Centos7搭建Redis单台和集群环境
    Linux系统:Centos7安装Jdk8、Tomcat8、MySQL5.7环境
    Linux系统:常用Linux系统管理命令总结
    转--->svn的使用
    开发中常见的问题
    1.NSThread
    用NSOperation和NSOperationQueue实现多线程编程
    很实用的时间比对算法
    简单的IOS6和IOS7通过图片名适配
    nginx完美支持tp框架
  • 原文地址:https://www.cnblogs.com/wym591273/p/10804731.html
Copyright © 2011-2022 走看看