我正在使用 Struts2 框架并使用 HttpClient 类来发出 put 请求。当我尝试在 LoginAction 类中调用 httpClient 的 requestEntity 方法时,出现以下错误。
严重:异常启动过滤器 struts2 java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity
我已经在类路径中包含了所有必需的 jar 文件。
请帮我弄清楚可能是什么问题。
我正在使用 Struts2 框架并使用 HttpClient 类来发出 put 请求。当我尝试在 LoginAction 类中调用 httpClient 的 requestEntity 方法时,出现以下错误。
严重:异常启动过滤器 struts2 java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity
我已经在类路径中包含了所有必需的 jar 文件。
请帮我弄清楚可能是什么问题。
如果您使用的是旧版本(apache commons 小于 3.0),那么该类在旧 jar 中将不可用。你必须使用Apache commons 3.0图书馆。org/apache/commons/httpclient/methods/RequestEntity类被添加,因为v3.0. 检查javadoc。
通常,如果我们没有在类路径中添加 jar(或没有在项目中),那么我们会得到ClassNotFoundException,如果我们在项目中包含 jar 并且它在类路径中但特定类不可用,那么我们会得到NoClassDefFoundError.