vaadin 22 找不到默认路由

vaadin 22 not finding the default route

我的 vaadin 网络应用程序有一个默认路由。 我是 运行 tomcat 8.5 没有 springboot.

package dev.mine.ui.user.views;


import com.vaadin.flow.router.BeforeEnterEvent;
import com.vaadin.flow.router.BeforeEnterObserver;
import com.vaadin.flow.router.Route;


@Route(value = "")
public class DefaultView implements BeforeEnterObserver
{
    public DefaultView()
    {
    }

    @Override
    public void beforeEnter(BeforeEnterEvent event)
    {
        event.forwardTo(SearchView.class);
    }
}

我没有 web.xml 而是使用 @WebServlet 注释

package dev.mine.servlets;

import javax.servlet.annotation.WebServlet;

import com.vaadin.flow.server.VaadinServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;

@WebServlet(urlPatterns =
{ "/*", "/VAADIN/*" }, name = "Mine", asyncSupported = true, initParams =
{
        @WebInitParam(name = "org.atmosphere.cpr.AtmosphereInterceptor", value = "dev.onepub.servlets.AtmosphereFilter"),
        @WebInitParam(name = "closeIdleSessions", value = "true"),

        /// changed this when we release.
        @WebInitParam(name = "productionMode", value = "false")

})
public class Servlet extends VaadinServlet
{
    @Override
    protected void servletInitialized() throws ServletException
    {
        super.servletInitialized();
    }
}

当我尝试访问时:

http://localhost:8080/context/

我期待进入默认视图。 相反,我得到了经典的 vaadin 未找到路由页面。

Could not navigate to ''
Available routes:

invite
....

This detailed message is only shown when running in development mode.

那我做错了什么?

您的 DefaultView 没有扩展 Div、VerticalLayout 等组件。没有组件,无法显示路线。