执行弹簧启动时出错
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了执行弹簧启动时出错相关的知识,希望对你有一定的参考价值。
我试图使用spring boot执行jsp但是我得到错误而不是显示jsp的主体它正在显示jsp文件名本身。我正在使用的是STS.In STS我选择springstarterproject-> web
我的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>com.springboot</groupId>
<artifactId>assignment4</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>springboot-index9</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.13.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>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
这是我的Controller
课程
@Controller
public class IController {
@RequestMapping(value="/first")
public String bankname(){
return "success";
}
}
启动spring boot应用程序的主程序
@SpringBootApplication
public class SpringbootIndex9Application {
public static void main(String[] args) {
SpringApplication.run(SpringbootIndex9Application.class, args);
}
}
这是我的application.properties
spring.mvc.view.prefix=/WEB-INF/jsp
spring.mvc.view.suffix=.jsp
而我的success.jsp
是
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
welcome
</body>
</html>
我使用的路径是http://localhost:8080/first 项目结构如图所示
答案
好像我遇到了你的问题。也许您将不得不添加一个依赖项。
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
添加此依赖项并尝试!
以上是关于执行弹簧启动时出错的主要内容,如果未能解决你的问题,请参考以下文章