java 中getstatus_java-调用response.getStatus()时出现NoSuchMethodError

我想这是某种依赖性问题,所以这是我的树:

[INFO] Sikor:BrowserGame:war:1.0-SNAPSHOT

[INFO] +- junit:junit:jar:3.8.1:test

[INFO] +- org.springframework:spring-context:jar:4.1.1.RELEASE:compile

[INFO] | +- org.springframework:spring-aop:jar:4.1.1.RELEASE:compile

[INFO] | +- org.springframework:spring-beans:jar:4.1.1.RELEASE:compile

[INFO] | +- org.springframework:spring-core:jar:4.1.1.RELEASE:compile

[INFO] | | \- commons-logging:commons-logging:jar:1.1.3:compile

[INFO] | \- org.springframework:spring-expression:jar:4.1.1.RELEASE:compile

[INFO] +- org.springframework:spring-webmvc:jar:4.1.1.RELEASE:compile

[INFO] | \- org.springframework:spring-web:jar:4.1.1.RELEASE:compile

[INFO] +- org.springframework:spring-context-support:jar:4.1.1.RELEASE:compile

[INFO] +- org.springframework.security:spring-security-web:jar:3.2.5.RELEASE:compile

[INFO] | +- aopalliance:aopalliance:jar:1.0:compile

[INFO] | \- org.springframework.security:spring-security-core:jar:3.2.5.RELEASE:compile

[INFO] +- org.springframework.security:spring-security-config:jar:3.2.5.RELEASE:compile

[INFO] +- org.springframework.security:spring-security-taglibs:jar:3.2.5.RELEASE:compile

[INFO] | \- org.springframework.security:spring-security-acl:jar:3.2.5.RELEASE:compile

[INFO] +- org.thymeleaf:thymeleaf-spring4:jar:2.1.3.RELEASE:compile

[INFO] | \- org.thymeleaf:thymeleaf:jar:2.1.3.RELEASE:compile

[INFO] | +- ognl:ognl:jar:3.0.6:compile

[INFO] | \- org.unbescape:unbescape:jar:1.0:compile

[INFO] +- org.thymeleaf.extras:thymeleaf-extras-springsecurity3:jar:2.1.1.RELEASE:compile

[INFO] +- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.2.7:compile

[INFO] +- org.hibernate:hibernate-entitymanager:jar:4.3.5.FINAL:compile

[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile

[INFO] | +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile

[INFO] | +- org.hibernate:hibernate-core:jar:4.3.5.Final:compile

[INFO] | | +- antlr:antlr:jar:2.7.7:compile

[INFO] | | \- org.jboss:jandex:jar:1.1.0.Final:compile

[INFO] | +- dom4j:dom4j:jar:1.6.1:compile

[INFO] | | \- xml-apis:xml-apis:jar:1.0.b2:compile

[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.4.Final:compile

[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile

[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile

[INFO] | \- org.javassist:javassist:jar:3.18.1-GA:compile

[INFO] +- org.hibernate:hibernate-validator:jar:4.3.2.Final:compile

[INFO] | \- javax.validation:validation-api:jar:1.0.0.GA:compile

[INFO] +- mysql:mysql-connector-java:jar:5.1.32:compile

[INFO] +- org.springframework:spring-orm:jar:4.1.1.RELEASE:compile

[INFO] | +- org.springframework:spring-jdbc:jar:4.1.1.RELEASE:compile

[INFO] | \- org.springframework:spring-tx:jar:4.1.1.RELEASE:compile

[INFO] +- org.springframework.data:spring-data-jpa:jar:1.6.4.RELEASE:compile

[INFO] | +- org.springframework.data:spring-data-commons:jar:1.8.4.RELEASE:compile

[INFO] | +- org.aspectj:aspectjrt:jar:1.8.1:compile

[INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.7.7:runtime

[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided

[INFO] +- org.slf4j:slf4j-api:jar:1.7.5:compile

[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile

[INFO] | \- log4j:log4j:jar:1.2.16:compile

[INFO] \- javax.mail:mail:jar:1.4:compile

[INFO] \- javax.activation:activation:jar:1.1:compile

从我发现的结果来看,Spring 4.1.1应该可以与javax.servlet 3.1.0一起使用,但是我在调​​用response.getStatus()时遇到了java.lang.NoSuchMethodError:javax.servlet.http.HttpServletResponse.getStatus() )放在我的拦截器中.

如果有人可以帮忙,我会很高兴.提前致谢.

编辑:添加了web.xml

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

mvc-dispatcher

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

/WEB-INF/config/mvc-dispatcher-servlet.xml

throwExceptionIfNoHandlerFound

true

1

mvc-dispatcher

/

springSecurityFilterChain

org.springframework.web.filter.DelegatingFilterProxy

springSecurityFilterChain

/*

org.springframework.web.context.ContextLoaderListener

contextConfigLocation

/WEB-INF/config/root-context.xml

EDIT2:更改了以下内容:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

至:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

version="3.1">

但是在调用response.getStatus()时仍然出现错误.

解决方法:

我在一个简单的tomcat:run上运行我的应用程序.将其部署到战争中并确保使用Tomcat 7之后,一切都很好.感谢所有评论员,您为我指明了正确的方向.干杯.

编辑:请记住,tomcat 7不支持servlet 3.1,因此您必须将servlet 3.0与tomcat 7或servlet 3.1和tomcat 8一起使用.

标签:java,spring,servlets,response

来源: https://codeday.me/bug/20191011/1889135.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值