来自commons-httpclient-3.1的URIUtil.encodePath发生了什么事? [英] What happened to URIUtil.encodePath from commons-httpclient-3.1?

查看:576
本文介绍了来自commons-httpclient-3.1的URIUtil.encodePath发生了什么事?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的是 724043 中所描述的内容,即编码URI的路径组件。推荐这样做的是 URIUtil 从Commons HttpClient 3.1。不幸的是,该类似乎从最新版本的HttpClient中消失了。来自HttpClient 4.1的类似命名的类, URIUtils 不提供相同的功能。这个类/方法是否已被移动到我不知道的其他库,还是刚刚走了?我最好只是将类从3.1版本复制到我的代码中,还是有一个更简单的方法?

I want to do what's described in question 724043, namely encode the path components of a URI. The class recommended to do that is URIUtil from Commons HttpClient 3.1. Unfortunately, that class seems to have disappeared from the most recent version of HttpClient. A similarly named class from HttpClient 4.1, URIUtils, doesn't provide the same functionality. Has this class/method been moved to some other library that I'm not aware of or is it just gone? Am I best off just copying the class from the 3.1 release into my code or is there a simpler way?

推荐答案

维护者该模块已经规定了您应该使用标准的JDK URI类代替:

The maintainers of the module have decreed that you should use the standard JDK URI class instead:


URI和URIUtils被标准Java URI替换的原因是
非常简单:没有人愿意维护这些类。

The reason URI and URIUtils got replaced with the standard Java URI was very simple: there was no one willing to maintain those classes.

有许多实用方法可以帮助解决java.net.URI实现的各种
问题,但是另外标准的
JRE类应该是足够的,不应该吗?

There is a number of utility methods that help work around various issues with the java.net.URI implementation but otherwise the standard JRE classes should be sufficient, should not they?

所以最简单的是从3.1发布并重复在自己的代码中执行的操作(或只是将方法/类复制到代码库中)。

So, the easiest is to look at the source of encodePath from the 3.1 release and duplicate what it does in your own code (or just copy the method/class into your codebase).

或者你可以去在您提到的问题上接受答案(但您似乎必须首先将URL分解成部分):

Or you could go with the accepted answer on the question you referred to (but it seems you have to break the URL into parts first):

new URI(
    "http", 
    "search.barnesandnoble.com", 
    "/booksearch/first book.pdf",
    null).toString();

这篇关于来自commons-httpclient-3.1的URIUtil.encodePath发生了什么事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆