仅一个文件的 jsp 导入错误:httpclient 无法解析

发布于 2024-12-14 13:15:37 字数 760 浏览 0 评论 0原文

<%@page import="org.apache.commons.httpclient.HttpClient"  %>

导致:“导入org.apache.commons.httpclient无法解析”

我正在使用STS(springframework)添加JSP文件,同一项目的同一目录中有2个jsp文件使用与上面相同的导入语句。 其中一个没问题,另一个出现错误,这会致命。为什么我会收到错误? STS 重启,maven clean,...,我还能做什么?

依赖项是手动添加的,如下所示,框架由 spring Roo 初始化。

<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.0-beta2</version>
</dependency>

顺便说一下,我从 apache.org 找到了以下信息:“Commons HttpClient 项目现已结束,不再开发。它的 HttpClient 和 HttpCore 模块已被 Apache HttpComponents 项目取代,它提供了更好的性能和更大的灵活性。”但是在检查了他们的示例代码之后,他们使用了与我相同的导入语句,如上所示。

<%@page import="org.apache.commons.httpclient.HttpClient"  %>

leads to: "The import org.apache.commons.httpclient cannot be resolved"

I am using STS (springframework) to add JSP files, there are 2 jsp files in same directory of a same project use the same import statement as above. One of them is okay, another get error, this kills. Why I get the error? STS restart, maven clean, ..., and what's more can I do?

The dependency was added by hand as the follows, the framework is initialed by spring Roo.

<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.0-beta2</version>
</dependency>

By the way, I found this information from apache.org: "The Commons HttpClient project is now end of life, and is no longer being developed. It has been replaced by the Apache HttpComponents project in its HttpClient and HttpCore modules, which offer better performance and more flexibility. " But after checking their sample codes, they use same import statement as mine, shown above.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹏雨一样淡蓝的深情 2024-12-21 13:15:37

顺便说一句,我从 apache.org 找到了以下信息:“Commons HttpClient 项目现已结束生命,不再开发。”

事实上,这被称为 HttpClient 3 .x。


“它的 HttpClient 和 HttpCore 模块已被 Apache HttpComponents 项目取代,后者提供了更好的性能和更大的灵活性。”

事实上,这被称为 HttpClient 4.x可以在此主页上找到。


但是在检查了他们的示例代码后,他们使用了与我相同的导入语句,如上所示。

根据您的 Maven 声明,您正在使用 HttpClient 4.x,因此您应该查看HttpClient 4.x示例代码 >。您会看到它说:

import org.apache.http.client.HttpClient;

Here's the HttpCient 4.x javadoc< /a>.请注意,您在 Maven 依赖项中引用了早期测试版。我建议选择一个更新且稳定的。

By the way, I found this information from apache.org: "The Commons HttpClient project is now end of life, and is no longer being developed."

Indeed, that was known as HttpClient 3.x.


"It has been replaced by the Apache HttpComponents project in its HttpClient and HttpCore modules, which offer better performance and more flexibility."

Indeed, that is known as HttpClient 4.x and is available at this home page.


But after checking their sample codes, they use same import statement as mine, shown above.

According to your Maven declatation, you're using HttpClient 4.x, so you should check the sample codes of HttpClient 4.x. You'll see that it says among others:

import org.apache.http.client.HttpClient;

Here's the HttpCient 4.x javadoc. Note that you're referencing an early beta version in your Maven dependency. I'd suggest to pick a more recent and stable one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文