I'm very new in Spring development. Please advice what I missed in my mini project. The Spring configuration defined in main.Main class by annotations (see below). Application starts succesefull, with message "...RequestMappingHandlerMapping : Mapped "{[/hello],methods=[GET]}..."
But when I tryed to open page http://localhost:8080/hello?name=MyUserName, I recieve error message: "...org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config..."
Seems to me that I has't completed configure DispatcherServlet to map controller output to View. But what I missed?
This is main.Main class:
@Configuration
@EnableWebMvc
@ComponentScan({"controllers"})
@EnableAutoConfiguration
public class Main {
public static void main(String[] args){
SpringApplication.run(Main.class, args);
}
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("WEB-INF/views/");
viewResolver.setSuffix(".html");
return viewResolver;
}
}
There is Controller intended to deal with user request:
@Controller
public class HelloController {
private static final String PAGE_URL = "/hello";
@RequestMapping(value = PAGE_URL,method = RequestMethod.GET)
public String getHelloMessage(@RequestParam("name") String name, Model model){
String str = (name == null) || name.equals("") ? "World" : name;
model.addAttribute("name", str);
return "hello";
}
}
This is View class (hello.html) located in the /WEB-INF/views/ directory Class project structure for HelloController application