0

I'm building a web app using spring boot, vaadin, and some static html pages (ui frameworks like bootstrap).

I want to have both Vaadin routes and static html pages in my project.

The static pages is just a basic index.html page which includes some css and js.

1) If i place the index.html in the webapp folder, it's accessible from the www.localhost:8080/ url, but then i got error from vaadin, saying :

the back-end doesn't accept POST requests to www.localhost:8080/

(because vaadin actually sends POST requests to that url)

2) If i add a @Route("") class, then the index.html is no lounger accessible, but then the back-end accepts the POST requests from the vaadin client...

3) I have no clue how to import static html to a @Route class. (no way with @HtmlImport)

Any Idea ?

AmirBll
  • 1,081
  • 1
  • 13
  • 25
  • Have you tried moving your vaadin servlet out of the way with the `vaadin.url-mapping` setting? – cfrick May 03 '19 at 18:20

2 Answers2

1

If you have a spring-boot starter vaadin app, then below should work:

1) Place your static page (for example, test.html) under the resources/static . (There is an example from official Spring's demo page under Add a Home Page section with a short explanation about the appropriate folder)

2) Specify mapping rules using a @Controller annotated class after that


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class GreetingController {

        @GetMapping(value = "/ownPage")
        public String index() {
                return "test.html";
        }

}

3) Navigate to yourURL\ownPage or any path value specified inside the @GetMapping. This will return the test.html page

anasmi
  • 2,562
  • 1
  • 13
  • 25
1

Thanks to cfrick for the clue. Have changed vaadin's servlet url mapping and left the index.html in the same place.

For people having same issues, everything's here: Changing vaadin servlet url mapping