2

我的 vaadin Web 应用程序有一个默认路由。我正在运行没有springboot的tomcat 8.5。

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 no route found 页面。

Could not navigate to ''
Available routes:

invite
....

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

那么我做错了什么?

4

1 回答 1

7

您的 DefaultView 不会扩展像 Div、VerticalLayout 等组件。如果没有组件,则无法显示 Route。

于 2022-01-29T05:49:14.077 回答