[SOLVED] spring boot i JSP

Odpowiedz Nowy wątek
2017-01-16 20:20
0

Cześć próbuje uruchomić spring boot z template w JSP. Niestety nie chce mi to ruszyć.
próbowałem poradników ze stron:
https://www.mkyong.com/spring[...]boot-hello-world-example-jsp/
http://www.leveluplunch.com/j[...]ing-started-with-spring-boot/
i jeszcze kilka innych opcji ale nie chce mi to ruszyć.
Na potrzeby testów pliki JSP mam w ścieżkach: src\main\webapp\WEB-INF\jsp oraz src\main\resources\META-INF\resources\WEB-INF\jsp

niestety wyskakuje mi poniższy błąd:

 2017-01-16 19:17:31.486 DEBUG 4332 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/WEB-INF/jsp/list.jsp]
2017-01-16 19:17:31.486 TRACE 4332 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler map [[email protected]2bb9e0c4] in DispatcherServlet with name 'dispatcherServlet'
2017-01-16 19:17:31.486 TRACE 4332 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : No handler mapping found for [/WEB-INF/jsp/list.jsp]
2017-01-16 19:17:31.486 TRACE 4332 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler map [org.springframework[email protected]23fad4a4] in DispatcherServlet with name 'dispatcherServlet'
2017-01-16 19:17:31.486 DEBUG 4332 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /WEB-INF/jsp/list.jsp
2017-01-16 19:17:31.488 TRACE 4332 --- [nio-8080-exec-1] .PathExtensionContentNegotiationStrategy : Loading default Java Activation Framework FileTypeMap
2017-01-16 19:17:31.491 DEBUG 4332 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/WEB-INF/jsp/list.jsp]
2017-01-16 19:17:31.491 TRACE 4332 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler map [or[email protected]1599b33d] in DispatcherServlet with name 'dispatcherServlet'
2017-01-16 19:17:31.491 TRACE 4332 --- [nio-8080-exec-1] o.s.w.s.h.BeanNameUrlHandlerMapping      : No handler mapping found for [/WEB-INF/jsp/list.jsp]
2017-01-16 19:17:31.491 TRACE 4332 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler map [[email protected]5b41a077] in DispatcherServlet with name 'dispatcherServlet'
2017-01-16 19:17:31.492 DEBUG 4332 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Matching patterns for request [/WEB-INF/jsp/list.jsp] are [/**]
2017-01-16 19:17:31.492 DEBUG 4332 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : URI Template variables for request [/WEB-INF/jsp/list.jsp] are {}
2017-01-16 19:17:31.493 DEBUG 4332 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapping [/WEB-INF/jsp/list.jsp] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[[email protected]56067e]]] and 1 interceptor
2017-01-16 19:17:31.493 TRACE 4332 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler adapter [org.springframework[email protected]b85dda]
2017-01-16 19:17:31.493 TRACE 4332 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Testing handler adapter [[email protected]596d13]
2017-01-16 19:17:31.493 DEBUG 4332 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/WEB-INF/jsp/list.jsp] is: -1
2017-01-16 19:17:31.493 TRACE 4332 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : Applying "invalid path" checks to path: WEB-INF/jsp/list.jsp
2017-01-16 19:17:31.493 TRACE 4332 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : Path contains "WEB-INF" or "META-INF".
2017-01-16 19:17:31.493 TRACE 4332 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : Ignoring invalid resource path [WEB-INF/jsp/list.jsp]
2017-01-16 19:17:31.493 TRACE 4332 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : No matching resource found - returning 404

application.properties

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.customer.ml</groupId>
    <artifactId>excel</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>excel</name>
    <description>Application to import data from xls/xlsx files</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.7</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
package org.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class App{

    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

Kontroller

package org.app.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/")
public classAppController {

    @RequestMapping
    public String hello(){
        return "list";
    }
}
edytowany 1x, ostatnio: lamek, 2017-01-17 10:41

Pozostało 580 znaków

2017-01-17 10:41
0

Wystarczyło zmienić w pom.xml wpisy dotyczące tomcata i usnąć scope. Po zmianie z:

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <scope>provided</scope>
        </dependency>

na:

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

I widoki w JSP działają.

Pozostało 580 znaków

Odpowiedz
Liczba odpowiedzi na stronę

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0