0

I have the same problem as mentioned in no mapping for GET but didn't work for me.

this is the structure : resource structure in my project

and this is my config class :

@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
                .addResourceHandler("/resources/**")
                .addResourceLocations("/resources/");
    }
}

and this is my controller:

 @RequestMapping("/")
public ModelAndView getHomepage() {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("home.html");
    return modelAndView;
}

and I have this in my html file:

<link rel="stylesheet" href="/css/home.css" />

but still get the error: No mapping for GET /css/home.css No mapping for GET /js/home.js

would be appreciated for any suggestions thank you

Omid Zare
  • 5
  • 2

1 Answers1

0

this is youre config

@Configuration
    @EnableWebMvc
    @ComponentScan("directory with youre getHomepage() controller ")
    public class MvcConfig implements WebMvcConfigurer {
    
    @Bean
        public ViewResolver viewResolver() {
            InternalResourceViewResolver resolver =
                    new InternalResourceViewResolver();
            resolver.setPrefix("/WEB-INF/views/"); //youre directory with home.jsp
            resolver.setSuffix(".jsp");
            return resolver;
        }
    }

this is youre controller

@Controller
@RequestMapping({"/"})
public class HomeController {
    @RequestMapping(method=GET)
    public String home() {
        return "home";
    }
}
Kofuki
  • 3
  • 3