测试开发进阶——spring boot——MVC——get访问——使用@RequestParam获取参数——使用默认值

控制器:

package com.awaimai.web;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class kzq
{

    @RequestMapping("/param/requestparam22")
    public String requestParam22(@RequestParam(value = "username",defaultValue = "abc21") String name)
    {

        return name;
    }


}

  

 

web访问:

 

 

 

 

 

 

posted @ 2021-07-31 17:15  小白龙白龙马  阅读(233)  评论(0)    收藏  举报