这是我的控制器:
@CrossOrigin(origins = "http://localhost:3000")
@RestController
@RequestMapping("/api/v1/employees")
public class EmployeeController {
@Autowired
private EmployeeService employeeService;
@GetMapping()
public List<Employee> getEmployeesBySearch(@Valid @ModelAttribute SearchDto searchDto) {
return employeeService.getEmployeesBySearch(searchDto);
}
}
这是我的搜索目标:
public class SearchDto {
private String firstName;
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
}
.
http://localhost:8080/api/v1/employees?firstName=%%%
http://localhost:8080/api/v1/employees?firstName=a%
http://localhost:8080/api/v1/employees?firstName=%a
每当get请求中有percent(%)符号时,它总是给出null值。
1条答案
按热度按时间zdwk9cvp1#
你应该给它编码。
https://www.urlencoder.org/
您的最终url如下所示