Spring Boot: Могу ли я обслуживать страницу index.html вместе с передачей параметра url? Требование: возможность считывать параметры URL-адреса запроса или заголовки запроса
IndexController
@RestController
public class IndexController {
@RequestMapping(value={"/", "/dashboard"})
public String index(@RequestHeader Map<String, String> headers) {
return "index.html/hi=abc";
}
}
WebApplicationConfig
@Configuration
public class WebApplicationConfig extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/notFound").setViewName("forward:/index.html");
}
@Bean
public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> containerCustomizer() {
return container -> {
container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,
"/notFound"));
};
}
}
Результат
Примечание: index.html находится в правильном месте (resources -> public). Без RestController и RequestMapping страница отображается. Я просто не уверен, как включить параметр URL с индексной страницы