java getparts,面对java.lang.NoSuchMethodError:HttpServletRequest.getParts()Ljava / util / Collection...

I've seen many issues related to this exception here in so and most of them are being solved by adding a "commons-file-upload" jar from apache. I tried to use this solution and I've added the same version of the jar for all my projects, but it does not seem to fix the problem, I'm still facing the problem. I know this question has been already asked, but I wonder if somebody could give me a hand with this specific problem. This is my stacktrace:

java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getParts()Ljava/util/Collection;

at fr.synomia.v4.ws.remotelayer.ws.rest.RESTServer.getParameters(RESTServer.java:378)

at fr.synomia.v4.ws.remotelayer.ws.rest.RESTServer.parseURLRequest(RESTServer.java:367)

at fr.synomia.v4.ws.remotelayer.ws.rest.RESTServer.access$0(RESTServer.java:354)

at fr.synomia.v4.ws.remotelayer.ws.rest.RESTServer$1.handle(RESTServer.java:67)

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)

at org.eclipse.jetty.server.Server.handle(Server.java:346)

at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442)

at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)

at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582)

at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)

at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)

at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)

at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)

at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)

at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)

at java.lang.Thread.run(Thread.java:662)

The exception is thrown when I invoke the method getParts from my class RestServer using HttpServletRequest, I've been looking for information and it says that the version of the jar used must be the same for all the projects and I did it that way, but not working.

The piece of code invoking the getParts() :

private Map getParameters(HttpServletRequest request,boolean jsonp, String callback) {

Map lsParameteres = new HashMap();

Collection parts = null;

try {

parts = request.getParts();//The exception begins here!

I will be grateful if somebody could help me, thanks for your time. Best regards.

解决方案

Things to check:

Be sure you are running Jetty 9 (or newer)

Make sure you have your WEB-INF/web.xml configured to use Servlet API 3.0 (or newer)

Make sure your build tool is using the servlet-api 3.1 (or newer) jars.

(Optionally) Make sure you have the same servlet api 3.1 jar in your WEB-INF/lib directory.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值