1
는봄 부팅 JSP 404.Whitelabel 오류 페이지는
HmisApplication.class
@SpringBootApplication
public class HmisApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(HmisApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(HmisApplication.class, args);
}
}
MainController.java
@Controller
public class WelcomeController {
@RequestMapping("/")
public String home(Map<String, Object> model) {
model.put("message", "HowToDoInJava Reader !!");
return "index";
}
@RequestMapping("/next")
public String next(Map<String, Object> model) {
model.put("message", "You are in new page !!");
return "next";
}
}
를 찾을 수 없음 (404)를 받고, 봄 부팅과 매우 간단한 JSP 페이지를로드 할 수 없습니다
application.properties
spring.profiles.active=dev,build-info
server.contextPath=/hmis
server.port=7070
spring.metrics.export.enabled=true
spring.main.banner-mode=off
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
application.message: Hello Phil
# HTTP encoding (HttpEncodingProperties)
spring.http.encoding.force-request=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
의 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd "> 4.0.0
<groupId>com.hmis</groupId>
<artifactId>hmis</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>hmis</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.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.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>5.21.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Tomcat Embed -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<!-- JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- To compile JSP files -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
MvcConfiguration.java
@Configuration
@EnableWebMvc
@ComponentScan
public class MvcConfiguration extends WebMvcConfigurerAdapter
{
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/jsp/");
resolver.setSuffix(".jsp");
resolver.setViewClass(JstlView.class);
registry.viewResolver(resolver);
}
}
파일 구조
├── src
├── main
│ ├── java
│ │ └── com
│ │ └── hmis
│ │ ├── HmisApplication.java
│ │ ├── MvcConfiguration.java
│ │ ├── WelcomeController.java
│ └── resources
│ └── application.properties
│ └── webapp
│ └── WEB-INF
│ └── jsp
│ └── index.jsp
│ └── next.jsp
봄 부팅 이미 것은 InternalResourceViewResolver 해결 프로그램을 제공하는 몇 가지 변화의 pom.xml 후 문제를 해결했다. MvcConfiguration 클래스를 완전히 제거하십시오. –
이 오류 메시지가 나타납니다. 예기치 않은 오류가 발생했습니다 (유형 = 내부 서버 오류, 상태 = 500). 이름이 'dispatcherServlet'인 서블릿에서 이름이 'next'인보기를 확인할 수 없습니다. –
webapp 폴더를 resources 폴더 아래가 아닌 src/main/webapp으로 이동하십시오. –