Đang chuẩn bị liên kết để tải về tài liệu:
Bắt đầu với IBM Websphere smash - p 28

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

252 Chapter 11 Framework Components All the methods we use in this class are static methods. The methods you will probably be using most are the relative URI methods, and they are shown in Listing 11.1. Listing 11.1 Java Relative URI API static java.lang.String getRelativeUri(java.lang.String path) static java.lang.String getRelativeUri(java.lang.String path, boolean encode) static java.lang.String getRelativeUri(java.lang.String path, java.util.Map queryParams) static java.lang.String getRelativeUri(java.lang.String path, java.util.Map queryParams, java.lang.String fragment) The relative URI methods each take in a path. The path can come in two flavors: relative to the context root or relative to the current script. The context root relative path is denoted with a starting /. So, if. | 252 Chapter 11 Framework Components All the methods we use in this class are static methods. The methods you will probably be using most are the relative URI methods and they are shown in Listing 11.1. Listing 11.1 Java Relative URI API static java.lang.String getRelativeUri java.lang.String path static java.lang.String getRelativeUri java.lang.String path boolean encode static java.lang.String getRelativeUri java.lang.String path java.util.Map java.lang.String java.lang.String queryParams static java.lang.String getRelativeUri java.lang.String path java.util.Map java.lang.String java.lang.String queryParams java.lang.String fragment The relative URI methods each take in a path. The path can come in two flavors relative to the context root or relative to the current script. The context root relative path is denoted with a starting . So if our calling script was located at http localhost 8080 path uriutils.gt we would get the URIs shown in Listing 11.2. Listing 11.2 Using the Java Relative URI API URIUtils.getRelativeUri images happy.jpg evaluates to . images happy.jpg URIUtils.getRelativeUri images happy.jpg evaluates to images happy.jpg The leading signals all the relative URI methods if your intention is to generate a URI that is relative to the context root. The API used in the preceding examples automatically encodes the URI. It is a convenience method for a call to the method that takes in a true boolean value for the encode parameter as shown in Listing 11.3. Listing 11.3 Using the Java Relative URI API URIUtils.getRelativeUri space images happy.jpg true evaluates to . space 20images happy.jpg If for some reason you want to suppress the encoding simply set the encode boolean parameter to false. The other variants of the API enable you to add parameters or a particular fragment to the URI. They are exemplified in Listing 11.4. Download from www.wowebook.com URIUtils 253 Listing 11.4 Using the Java Relative URI API HashMap params new HashMap String String .