Angular 12 Front End Верните кодированный запрос получитьJAVA

Программисты JAVA общаются здесь
Anonymous
Angular 12 Front End Верните кодированный запрос получить

Сообщение Anonymous »

Я использую mysql для моего db, Spring для моего бэкэнда и angular для моего блюда. Мой фронт - это бросает эту странную ошибку, когда его правильно маршрутируется: нажмите здесь, чтобы увидеть его
Как вы видите, путь в конце IS %7bid %7d (выглядит как {id} из бэкэнда)

. http код ошибки всегда один из 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 3: 400 , 400 или 500

Backend выглядит нормально, и я действительно когда-либо получал этот код ошибки:

Код: Выделить всё

2022-02-04 15:30:31.465  WARN 15200 --- [nio-8081-exec-7] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'; nested exception is java.lang.NumberFormatException: For input string: "{id}"]
< /code>

Вот контроллер [b] < /strong> (a get-запрос):
< /p>
@CrossOrigin
@RestController
@RequestMapping(path = "/api/patient")
public class PatientPortalController {
@Autowired
private PatientPortalRepo patientPortalRepo;

@PostMapping("/patientportal")
public PatientPortal createPatientPortal(@RequestBody PatientPortal patientportal) {
return patientPortalRepo.save(patientportal);
}

@GetMapping("/patientportal/{id}")
public ResponseEntity getpatientPortal(@PathVariable Long id){
PatientPortal patientportal = patientPortalRepo.findByPatientPortalId(id);
if(patientportal.getId()>0 && patientportal!=null)
return new ResponseEntity(patientportal, HttpStatus.OK);
return new ResponseEntity(patientportal, HttpStatus.BAD_REQUEST);
}}
Some things worth of note that I've tried[/b] with the backend

Tried changing response entity to of type long and returning id, tried refactoring the controller numerous times, tried changing decorators/paths around, 20x checked the types are correct, checked if any types other Чем идентификатор бросает его , проверил, если у меня была какая -либо безопасность, которая отрицала доступ к доступу , проверяю, если добавление Onetoone заставит его появиться на переднем конце . Он прекрасно работает на бэкэнд ( возвращает список , что я предполагаю, так это patentportal object ), но я либо неправильно, , есть , мне не хватает , есть ошибка типа , или . я думаю, что однако проблема заключается в передней части .

Вот код, в котором я называю метод фронта жестко кодированное значение для тестирования < /strong>: < /p>
this.patientloginservice.loginPatient(this.patient).subscribe(data=>(this.route.navigate(['api/patient/patientportal/1'])),error=>console.log('error'));
< /code>

и вот , где этот код обслуживается < /strong>: < /p>
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { Observable } from 'rxjs'
import { PatientPortal } from './patientportal';

@Injectable({
providedIn: 'root'
})
export class PatientService {

private baseURL = "http://localhost:8081/api/patient/patientportal";

constructor(private httpClient: HttpClient) { }

getPatientPortalList(): Observable {
return this.httpClient.get(`${this.baseURL}`);
}

createPatientPortal(patientportal: PatientPortal): Observable{
return this.httpClient.post(`${this.baseURL}`, patientportal);
}

getPatientPortalById(id: number): Observable{
return this.httpClient.get(`${this.baseURL}/{id}`);
}

updatePatientPortal(id: number, patientportal: PatientPortal): Observable{
return this.httpClient.put(`${this.baseURL}/{id}`, patientportal);
}

deletePatientPortal(id: number): Observable{
return this.httpClient.delete(`${this.baseURL}/{id}`);
}
}
< /code>
Любая помощь будет высоко оценена, спасибо. Опять же, как я сказал, маршрут правильно направлены, насколько я могу судить, но таблица рендеринга не заполняет данные, и это выбрасывает эту ошибку. Я использую логин
для перенаправления/маршрута to a детали пациента .


Подробнее здесь: https://stackoverflow.com/questions/709 ... et-request

Вернуться в «JAVA»