学到一寸是一寸
2022-03-13 13:09
采纳率: 66.7%
浏览 58
已结题

【VUE】【Spring Boot】前端向后端get方式传递输入值为参数,后端接收参数显示null

前端VUE

      <el-input v-model="name">
        <el-button type="primary" @click="handleSearch">查询</el-button>
      </el-input>
    handleSearch() {
      console.log(this.name)
      fetchData(this.name)
        .then(({ data }) => {
          this.list = data
          console.log(this.list)
        })
    }
export function fetchData(name) {
  return request({
    url: '/search',
    method: 'get',
    params: name
  })
}

后端Spring Boot

@CrossOrigin
@RestController
public class TestController {
    @Autowired
    private testService tServ;

    @GetMapping("/search")
    public GeneralResponse searchEntity(String name) {
        System.out.println(name);
        return new GeneralResponse(GeneralResponse.SUCCESS,tServ.searchData(name),null);
    }
}
报错

输入了一个值后,点击查询,打印name为null

img

求解决

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题