Spring Boot - Liste des komplexen Objekts bei GET -Mapping

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Spring Boot - Liste des komplexen Objekts bei GET -Mapping

by Anonymous » 13 Feb 2025, 22:10

Ich habe eine einfache @getmapping wie folgt:

Code: Select all

@GetMapping
public Page search(Pageable pageable, List filters) {
return Page.empty();
}
< /code>
FilterCriterion.java
:

Code: Select all

public class FilterCriterion {
private @NotBlank @Size(min = 1, max = 255) String column;
private @NotNull FilterOperation operation;
private @Size(max = 255) String value;
// getters, setters, no-args and all-args constructor
}
< /code>
FilterOperation.java
:

Code: Select all

public enum FilterOperation {
EQUALS,
NOT_EQUALS,
CONTAINS,
LT,
LTE,
GT,
GTE
}
Problem
Beim Senden von GET wie diese

Code: Select all

http://localhost:8080/departments?page=0&size=10&sort=name,asc&filters[0].column=name&filters[0].operation=EQUALS&filters[1].value=foo

Ich erhalte diesen Fehler:

Code: Select all

java.lang.IllegalStateException: No primary or single unique constructor found for interface java.util.List
< /code>
Changing List
zu arrayList löst die Ausnahme auf, führt jedoch dazu, dass nur die lehbaren Datenfelder einen Wert haben. Die Liste der Filterkriterien ist immer noch leer.>

Top