Skip to content
Advertisement

Spring-Boot MVC JPA Filters

Let me start by saying I’m fairly new to Spring Boot so apologies if I’m making a silly mistake somewhere. I am trying to retrieve the value of my form post using @RequestParam so I can utilize it in a JPA query to return kids who have a specific pet type. I’ve done other JPA queries and had successful results, but getting the Enum value from a populated select so I can pass it back to the controller query has me stumped.

I keep getting the error:

Required request parameter ‘p’ for method parameter type String is not present

I need to pass the petType to the Post method findByPet_PetTypeEquals in order to retrieve what kids have that particular pet type. I just can’t figure out how to pass that form data back to the controller.

Kid class:

JavaScript

Pet class:

JavaScript

PetType Enum:

JavaScript

Relevant Controller Methods:

JavaScript

Form:

JavaScript

Repo:

JavaScript

Any advice or guidance is greatly appreciated! Thank you.

Advertisement

Answer

as method param in findByPet_PetTypeEquals, give Enum instead of String.

@Enumerated is just an annotation that allows JPA/hibernate to store enum as string in DB and while retrieving convert string to enum. So, in your method param, it should be enum type

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement