Maven Dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
index.jsp page
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>index</title>
</head>
<body>
<h3>Application working</h3>
</body>
</html>
spring controller
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class SSOAppController {
@RequestMapping("/")
public String indexPage() {
return "index";
}
}
在服务器上运行应用程序时发生异常: java.lang.NoSuchMethodError:javax.servlet.http.HttpServletRequest.getHttpServletMapping()Ljavax / servlet / http / HttpServletMapping; org.springframework.boot.web.servlet.support.ErrorPageFilter.forwardToErrorPage(ErrorPageFilter.java:197) org.springframework.boot.web.servlet.support.ErrorPageFilter.handleException(ErrorPageFilter.java:180) org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:145) org.springframework.boot.web.servlet.support.ErrorPageFilter.access $ 000(ErrorPageFilter.java:66) org.springframework.boot.web.servlet.support.ErrorPageFilter $ 1.doFilterInternal(ErrorPageFilter.java:105) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:123) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
答案 0 :(得分:0)
将以下属性添加到pom.xml并进行构建,
注意:请根据您的环境更新版本。
<properties>
<tomcat.version>7.0.81</tomcat.version>
<servlet-api.version>3.0.1</servlet-api.version>
</properties>