Code: Select all
@Controller
public class SayHelloController {
@RequestMapping("say-hello-jsp")
public String sayHelloJsp() {
return "sayHello";
}
}
< /code>
Mit der folgenden Anwendung.Properties:
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
logging.level.org.springframwork=debug
< /code>
und Sayhello.jsp: < /p>
My first JSP file!
Hello
This is the text we want to show
Code: Select all
: GET "/say-hello-jsp", parameters={}
: Mapped to com.in28minutes.springboot.myfirstwebapp.hello.SayHelloController#sayHelloJsp()
: Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8]
: View name 'sayHello', model {}
: Forwarding to [/WEB-INF/jsp/sayHello.jsp]
: "FORWARD" dispatch for GET "/WEB-INF/jsp/sayHello.jsp", parameters={}
: Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
: "Path with "WEB-INF" or "META-INF": [WEB-INF/jsp/sayHello.jsp]"
: Resource not found
< /code>
Was ist nicht sinnvoll, da die Datei vorhanden ist, Beweis: < /p>
macbook-air:jsp gerald$ pwd
/Users/gerald/IdeaProjects/myfirstwebapp/src/main/resources/META-INF/resources/WEB-INF/jsp
macbook-air:jsp gerald$ ls
sayHello.jsp
< /code>
Außerdem habe ich Jasper als Abhängigkeit in meinem pom.xml < /p>
hinzugefügt
org.apache.tomcat.embed
tomcat-embed-jasper
provided