这是我的控制器代码
@GetMapping("/customerWasteRequest/{customer}")
public List<CustomerWasteRequest> getCustomerWasteRequest(@PathVariable String customer) {
return service.fetchWasteRequestByCustomer(customer);
}
这是我的服务代码
public class CustomerWasteRequestService{
@Autowired
private CustomerWasteRequestRepository repo;
public List<CustomerWasteRequest> fetchWasteRequestByCustomer(String customer) {
return repo.findByCustomer(customer);
}
}
存储库代码
@Repository
public interface CustomerWasteRequestRepository extends JpaRepository<CustomerWasteRequest, Integer> {
public List<CustomerWasteRequest> findByCustomer(String customer);
}
当我调用函数-getCustomerWasteRequests
private baseUrl = 'http://localhost:8080/customerWasteRequest';
getCustomerWasteRequests(customer:string) : Observable<any>{
return this.http.get(`${this.baseUrl}/${customer}`);
}
这给了我错误
{“ cause”:{“ cause”:null,“ message”:“对于输入字符串:” newcustomer“”}},“ message”:“无法从[java.lang.String]类型转换为[值'newcustomer'的java.lang.Integer];嵌套异常为java.lang.NumberFormatException:对于输入字符串:“ newcustomer”“}
在http:// localhost:8080 / customerWasteRequests / newcustomer
答案 0 :(得分:0)
“无法将类型'newcustomer'的类型[java.lang.String]转换为[java.lang.Integer]
您进入实体customer
的财产CustomerWasteRequest
是否具有类型Integer
而不是String
?