Я создал приложение Springboot с Maven и добавил контроллер здесь
package ml.developer45.boot.ctrl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@Controller
public class MainCtrl {
@RequestMapping("/")
public String hello()
{
return "index";
}
}
это мой основной класс с методом springapplication.run
package ml.developer45.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
это мой файл 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>ml.developer45</groupId>
<artifactId>demo-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<packaging>war</packaging>
</project>
и это мой файл application.properties
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
spring.mvc.static-path-pattern=/resources/**
это вывод консоли без отображения для ошибки GET /WEB-INF/views/index.jsp
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-05-03 17:40:36.936 INFO 21051 --- [ main] ml.developer45.boot.DemoApplication : Starting DemoApplication on 45davy-PC with PID 21051 (/home/davy/Documents/workspace-spring-tool-suite-4-4.2.1.RELEASE/demo/target/classes started by davy in /home/davy/Documents/workspace-spring-tool-suite-4-4.2.1.RELEASE/demo)
2019-05-03 17:40:36.941 INFO 21051 --- [ main] ml.developer45.boot.DemoApplication : No active profile set, falling back to default profiles: default
2019-05-03 17:40:43.804 INFO 21051 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-05-03 17:40:43.890 INFO 21051 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-05-03 17:40:43.890 INFO 21051 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2019-05-03 17:40:44.085 INFO 21051 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-05-03 17:40:44.085 INFO 21051 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 7050 ms
2019-05-03 17:40:44.814 INFO 21051 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-05-03 17:40:45.200 INFO 21051 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-05-03 17:40:45.208 INFO 21051 --- [ main] ml.developer45.boot.DemoApplication : Started DemoApplication in 8.862 seconds (JVM running for 9.429)
2019-05-03 17:40:55.213 INFO 21051 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-05-03 17:40:55.213 INFO 21051 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-05-03 17:40:55.222 INFO 21051 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 9 ms
2019-05-03 17:40:55.289 WARN 21051 --- [nio-8080-exec-1] o.s.web.servlet.PageNotFound : No mapping for GET /WEB-INF/views/index.jsp
2019-05-03 17:40:56.020 WARN 21051 --- [nio-8080-exec-2] o.s.web.servlet.PageNotFound : No mapping for GET /WEB-INF/views/index.jsp
Я пытаюсь отобразить страницу jsp в папке src / main / webapp / WEB-INF / views с моего контроллера, но она продолжает давать сбой, я даже меняю упаковку на war с jar, но она также не удалась !!
Помогите пожалуйста !!!!!!!!!!