【问题标题】:java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getHttpServletMapping()Ljavax/servlet/http/HttpServletMapping;java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getHttpServletMapping()Ljavax/servlet/http/HttpServletMapping;
【发布时间】:2019-06-03 03:33:22
【问题描述】:
    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)

【问题讨论】:

  • 在我的 Spring Boot 应用程序中,我有一个控制器类和一个 intex.jsp 页面。我已经在 application.properties 文件中映射了视图。当我运行此应用程序时,我收到此错误。请帮忙。

标签: spring-boot


【解决方案1】:

将以下属性添加到您的 pom.xml 并构建,

注意:根据您的环境更新版本。

<properties>
        <tomcat.version>7.0.81</tomcat.version>
        <servlet-api.version>3.0.1</servlet-api.version>
    </properties>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-10
    • 2014-04-05
    • 2014-12-24
    • 2015-03-19
    • 2016-06-15
    • 1970-01-01
    相关资源
    最近更新 更多