Route parameter always null in Vaadin 24 Spring Boot project

Hi,
I’m using Vaadin 24 with Spring Boot 3.0.5 and Java 17. I have a simple view with a route parameter, but the parameter is always null when I navigate to the view.

Example code:

@Route("test/:id")
public class TestView extends VerticalLayout implements HasUrlParameter<Integer> {
    @Override
    public void setParameter(BeforeEvent event, @OptionalParameter Integer id) {
        System.out.println("TEST DEBUG: id = " + id);
        add(new H1("Test ID: " + id));
    }
}

When I go to /test/1, the output is always id = null.

  • The route is registered and visible in the route registry.
  • I have no conflicting REST controllers or static resources.
  • My main application class is in the correct package.
  • I have tried both Integer and String as the parameter type.

Here is a link to my full Github project → GitHub - Jmorkcho/CinemaApp at wip.
These are the 2 views I’ve tested this:
CinemaApp/src/main/java/com/finals/cinema/view/MovieDetailsView.java at wip · Jmorkcho/CinemaApp · GitHub
and
CinemaApp/src/main/java/com/finals/cinema/view/TestView.java at wip · Jmorkcho/CinemaApp · GitHub

And here is a screenshot:
image

Console output:

TEST DEBUG: id = null
DEBUG: setParameter called with id = null
DEBUG: setParameter called with id = null

What could cause Vaadin to always pass null for the route parameter?
Thanks for the help in advance,
Y. P.

You are mixing different concepts. Route Parameter are not related to Url Parameter.

Replace HasUrlParameter with BeforeEnterObserver and get your value from event.getRouteParameters().get("id").

P.S. your Spring Boot Version is EoL

1 Like