InternalResourceViewResolver not resolving views properly

by Bill L   Last Updated November 08, 2018 23:26 PM

I have no idea what we're doing wrong here. I'm trying to set up a single page Spring MVC project so I can look into things. I have a single screen, greeting.html that I'm trying to load. Here's my controller class to load it:

public class GreetingController {

    public String getGreeeting(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) {
        model.addAttribute("name", name);

        return "greeting";


This works fine when greeting.html is in /resources/templates/greeeting.html. However, I'd like it behind a WEB-INF folder. I've tried placing it in WEB-INF/views/greeting.html and webapp/WEB-INF/views/greeting.html. I then try and use an InternalResourceViewResolver as I've read online:

public InternalResourceViewResolver viewResolver() {
    InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();

    return viewResolver;

From my understanding, this should allow it to find greeting.html behind one of my WEB-INF folder setups. However, when I go to localhost:8080/greeting, I get a 404 along with the following message in the console:

WARN 1439 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler : Path with "WEB-INF" or "META-INF": [WEB-INF/views/greeting.html]

I'm at a complete loss as to what's even going on or how to fix it, every single tutorial online does this exact thing and has no problems, I can't seem to find anyone online with this same issue. Any guidance at all would be helpful here.

Answers 1

Hi as i understand from your question you are using spring boot By default spring boot searches for src/main/resources/templates folder If you used some dependency like :


This will enable thymeleaf by default.

To override you ViewResolver you need

In spring boot you can make such config in your file:


or you can write custom resolver configuration with java config :

public class MvcConfiguration extends WebMvcConfigurerAdapter
    public void configureViewResolvers(ViewResolverRegistry registry) {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();

    public void configureDefaultServletHandling(
            DefaultServletHandlerConfigurer configurer) {

I think this is helpful

Mykhailo Moskura
Mykhailo Moskura
November 08, 2018 23:13 PM

Related Questions

Trace id is not same when using Spring Oauth 2

Updated March 13, 2019 12:26 PM

Spring Integration Java DSL with H2 adapter

Updated March 10, 2018 02:26 AM