Skip to content
Advertisement

Spring Boot Patient Application

an image of code for some reason

I am trying to have a little API run. Everything runs fine but I have to make an addition and am confused. I have to have it so in the URL when I type “localhost:8080/api/v1/{illness}” it will display the names of the people with that illness…help. I have included the two classes that I have. I didn’t include my patient class. It’s just the constructors and getters/setters for name, gender, illness, and id. I also didn’t include the main well because its not needed

JavaScript
JavaScript
JavaScript

Advertisement

Answer

First of all you need to change your controller function to something like this:

JavaScript

I don’t understand why you called your service function with two arguments, because it can accept only one. You also need to make this function return list of patients instead of void. And illness is just a path variable, you use it in different functions, so you should understand it. And in your patient service you just need to use filter function, so it will look similiar to this:

JavaScript
Advertisement