在手册的第页
Differences Between V10 and V8 Applications
,这里有一个示例代码,供那些想编写
UI
Vaadin Flow
.
(将原始mydomain.com更改为
example.com
@WebServlet(urlPatterns = "/*", name = "myservlet", asyncSupported = true,
// Example on initialization parameter configuration
initParams = {
@WebInitParam(name = "frontend.url.es6", value = "http://example.com/es6/"),
@WebInitParam(name = "frontend.url.es5", value = "http://example.com/es5/") })
// The UI configuration is optional
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public class MyServlet extends VaadinServlet {
}
// this is not necessary anymore, but might help you get started with migration
public class MyUI extends UI {
protected void init(VaadinRequest request) {
// do initial steps here.
// previously routing
}
}
从语法上说,这要么是不正确的,要么是要写进两个单独的文本中
.java
文件夹。
还是应该
MyServlet
必须在
MyUI
类,就像在Vaadin 8中默认做的那样?这样地:
package com.raddkit;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.server.VaadinRequest;
import com.vaadin.flow.server.VaadinServlet;
import com.vaadin.flow.server.VaadinServletConfiguration;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
public class MyUI extends UI {
protected void init ( VaadinRequest request ) {
}
@WebServlet ( urlPatterns = "/*", name = "myservlet", asyncSupported = true,
// Example on initialization parameter configuration
initParams = {
@WebInitParam ( name = "frontend.url.es6", value = "http://example.com/es6/" ) ,
@WebInitParam ( name = "frontend.url.es5", value = "http://example.com/es5/" ) } )
// The UI configuration is optional
@VaadinServletConfiguration ( ui = MyUI.class, productionMode = false )
public class MyServlet extends VaadinServlet {
}
}