前端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