Spring boot mapping static html

Tags: , , ,

I want to create spring boot web application.

I have two static html files: one.html, two.html.

I want to map them as follows


without using template engines (Thymeleaf).

How to do that? I have tried many ways to do that, but I have 404 error or 500 error (Circular view path [one.html]: would dispatch back to the current handler URL).

OneController.java is:

public class OneController {
    public String one() {
        return "static/one.html";

Project structure is

enter image description here


Please update your WebMvcConfig and include UrlBasedViewResolver and /static resource handler. Mine WebConfig class looks as follows:

public class WebConfig extends WebMvcConfigurerAdapter {

    public void addResourceHandlers(ResourceHandlerRegistry registry) {

    public ViewResolver viewResolver() {
        UrlBasedViewResolver viewResolver = new UrlBasedViewResolver();
        return viewResolver;


I have checked it and seems working.

Maciej’s answer is based on browser’s redirect. My solution returns static without browser interaction.

Source: stackoverflow