Search code examples
javaspringspring-boottomcat

spring boot tomcat jsp is downloaded not rendered


I am bootstrapping my spring application to spring boot and I have the problem that the embedded tomcat is not rendering the jsp files instead the file will be downloaded.

I have googled and tried everything what I have found so far but I still do anything wrong.

I have the following dependencies in my pom.xml file

        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
    </dependency>

    <!-- Need this to compile JSP -->
    <dependency>
        <groupId>org.eclipse.jdt.core.compiler</groupId>
        <artifactId>ecj</artifactId>
        <version>4.6.1</version>
    </dependency>

Clipping from the application.properties

server.port=8080
spring.mvc.view.prefix=/
spring.mvc.view.suffix=.jsp

Clipping from the Controller

    @GetMapping(value= "/")
public String showPage(Model theModel) {

    theModel.addAttribute("scrumbled", new Scrumbled());

    return "main";
}

What am I doing wrong that the jsp file is downloaded instead of showing and rendered in the browser?

Thanks in Advance


Solution

  • I have solved the issue.

    The problem was a corrupted jar dependency. I had to maven clean, maven install the whole project to see the error. After deleting the jar from the file system maven downloaded the dependency again and now its working.