We have a Vaadin 8 application that is running with SpringBoot (1.5.9-RELEASE).
I have two views that are "view1" and "view2".
The problem is that Vaadin only recognizes "example.com/#!view1" and "example.com/#!view2".
What I want is "example.com/view1" and "example.com/view2". Despite using SpringViews, etc. I can't seem to make it work. All I get are 404's if I remove the "#!" from the path.
Here are some of my configuration settings. Please let me know if you need more.
Thanks!
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
....
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<vaadin.version>8.3.1</vaadin.version>
</properties>
....
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
AppConfiguration.java
@SpringBootConfiguration
@ComponentScan("com.example")
@EntityScan("com.example")
@EnableVaadin
@EnableVaadinServlet
public class AppConfiguration {
}
AppUI.java
@SpringUI
@Theme("valo")
public class AppUI extends UI {
....
@PostConstruct
private void setup() {
Navigator navigator = new Navigator(this, this);
navigator.addView("", welcomeView);
navigator.addView("view1", view1View);
navigator.addView("view2", view2View);
}
View1 and View2
@SpringComponent
@UIScope
@SpringView(name = View1View.NAME, ui = AppUI.class)
public class View1View extends VerticalLayout implements View, Serializable {
public static final String NAME = "view1";
....
@SpringComponent
@UIScope
@SpringView(name = View2View.NAME, ui = AppUI.class)
public class View2View extends VerticalLayout implements View, Serializable {
public static final String NAME = "view2";
....
Oh my word. Been looking all day and I stumbled on my own answer.
Adding @PushStateNavigation
to your UI element fixes the issue.
Hope this answer helps someone else.