I am having issue to display jsp page in Spring-MVC. This is a basic hello world Spring-MVC with Gradle and IntelliJ CE:
I get the following error page:
Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
}
}
plugins {
id 'java'
}
group 'com.helloct'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
baseName = 'gs-serving-web-content'
version = '0.1.0'
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-devtools")
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework:spring-jdbc")
compile("com.h2database:h2")
compile("com.fasterxml.jackson.core:jackson-databind")
compile('javax.servlet:jstl')
compile('org.apache.tomcat.embed:tomcat-embed-jasper')
compile 'javax.servlet.jsp:javax.servlet.jsp-api'
testCompile("junit:junit")
}
the The view resolver file:
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "hello")
public class WebConfig implements WebMvcConfigurer {
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setViewClass(JstlView.class);
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
return resolver;
}
}
The controller page:
@Controller
public class JSPController {
@GetMapping("/jspPage")
public String home(){
return "jspPage";
}
}
The jsp page location:
Content of the application.properties file:
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
Using the default template engine, the page displays correctly but using jsp, it doesn't work
Log error:
https://hastebin.com/lijekesoti.apache
NOTE: I know Thymleleaf is the recommanded template for Spring but I want work with JSP for some reason
UPDATE
After reading this post with the help of paulsm4 answer, removing the following line:
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
and removing the view resolver file solved my issue.