Java 找不到404进行更新
Im试图通过在url中提供用户的电子邮件将分数发送到数据库这是postman中的结果:Java 找不到404进行更新,java,postman,put,Java,Postman,Put,Im试图通过在url中提供用户的电子邮件将分数发送到数据库这是postman中的结果: url:http://localhost:8085/quiz?email=user@gmail.com&score=100 "timestamp": "2021-05-22T13:03:15.451+00:00", "status": 404, "error": "Not Found"
url:http://localhost:8085/quiz?email=user@gmail.com&score=100
"timestamp": "2021-05-22T13:03:15.451+00:00",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/quiz"
控制器中的my method Updatescore:
@PutMapping(path = "/quiz")
public void Updatescore(@RequestParam(required = true) String email, @RequestParam(required = true) int score) {
paserv.updatePatientScore(email, score);
}
}
服务中的my method updatePatientScore:
@Transactional
public void updatePatientScore(String email, int score) {
patient p = paRepo.findByEmail(email);
// .orElseThrow(() -> new IllegalStateException("student with id" + studentID +
// "does not exist"));
if (score != 0) {
p.setScore(score);
}
}
请确保应用程序已启动并正在运行,并验证URI资源是否统一,因为 RESTAPI-404表示“未找到服务器无法找到请求的资源”
参考资料:您的
@RestController
是否有@RequestMapping
注释?请发布并提供您发送的请求(例如,作为curl
-命令)。--PUT
似乎不合适,可能会被替换为POST
动词,因为:“…成功放置给定的表示将意味着随后对同一目标资源的访问将导致在200(OK)响应中发送等效的表示…”目前还不清楚您在测试中发送了什么HTTP谓词。另外,-正如@geobreze所提到的,-请检查@RestController
是否有@RequestMapping
注释。我不知道该怎么办?