111111
精灵王
精灵王
  • 注册日期2010-12-08
  • 发帖数640
  • QQ
  • 火币1103枚
  • 粉丝120
  • 关注75
  • 社区明星
阅读:3760回复:0

java.net.URLEncoder翻译-JSP教程,Java技巧及代码

楼主#
更多 发布于:2010-12-15 13:14
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">
<!--newpage-->
<html>
<head>
<!-- generated by javadoc (build 1.4.2-rc) on fri jun 13 00:14:25 pdt 2003 -->
<title>
urlencoder (java 2 platform se v1.4.2)
</title>

<meta name="keywords" content="java.net.urlencoder class">
<meta name="keywords" content="encode()">

<link rel ="stylesheet" type="text/css" href="../../stylesheet.css" title="style">
<script type="text/javascript">
function windowtitle()
{
    parent.document.title="urlencoder (java 2 platform se v1.4.2)";
}
</script>

</head>
<body bgcolor="white">

<!-- ========= start of top navbar ======= -->
<a name="navbar_top"><!-- --></a>
<a href="#skip-navbar_top" title="skip navigation links"></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0" summary="">
<tr>
<td colspan=3 bgcolor="#eeeeff" class="navbarcell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3" summary="">
  <tr align="center" valign="top">
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="../../overview-summary.html"><font class="navbarfont1"><b>overview</b></font></a> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="package-summary.html"><font class="navbarfont1"><b>package</b></font></a> </td>
  <td bgcolor="#ffffff" class="navbarcell1rev">  <font class="navbarfont1rev"><b>class</b></font> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="class-use/urlencoder.html"><font class="navbarfont1"><b>use</b></font></a> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="package-tree.html"><font class="navbarfont1"><b>tree</b></font></a> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="../../deprecated-list.html"><font class="navbarfont1"><b>deprecated</b></font></a> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="../../index-files/index-1.html"><font class="navbarfont1"><b>index</b></font></a> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="../../help-doc.html"><font class="navbarfont1"><b>help</b></font></a> </td>
  </tr>
</table>
</td>
<td align="right" valign="top" rowspan=3><em>
<b>java<sup><font size=-2>tm</font></sup> 2 platform<br>std. ed. v1.4.2</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="navbarcell2"><font size="-2">
 <a href="../../java/net/urldecoder.html" title="class in java.net"><b>prev class</b></a>
 <a href="../../java/net/urlstreamhandler.html" title="class in java.net"><b>next class</b></a></font></td>
<td bgcolor="white" class="navbarcell2"><font size="-2">
  <a href="../../index.html" target="_top"><b>frames</b></a>  
 <a href="urlencoder.html" target="_top"><b>no frames</b></a>  
 <script type="text/javascript">
  <!--
  if(window==top) {
    document.writeln(<a href="../../allclasses-noframe.html"><b>all classes</b></a>);
  }
  //-->
</script>
<noscript>
  <a href="../../allclasses-noframe.html"><b>all classes</b></a>
</noscript>

</font></td>
</tr>
<tr>
<td valign="top" class="navbarcell3"><font size="-2">
  summary: nested | field | constr | <a href="#method_summary">method</a></font></td>
<td valign="top" class="navbarcell3"><font size="-2">
detail: field | constr | <a href="#method_detail">method</a></font></td>
</tr>
</table>
<a name="skip-navbar_top"></a>
<!-- ========= end of top navbar ========= -->

<hr>
<!-- ======== start of class data ======== -->
<h2>
<font size="-1">
java.net</font>
<br>
class urlencoder</h2>
<pre>
<a href="../../java/lang/object.html" title="class in java.lang">java.lang.object</a>
  <img src="../../resources/inherit.gif" alt="extended by"><b>java.net.urlencoder</b>
</pre>
<hr>
<dl>
<dt>public class <b>urlencoder</b><dt>extends <a href="../../java/lang/object.html" title="class in java.lang">object</a></dl>

<p>
utility class for html form encoding. this class contains static methods
 for converting a string to the <code>application/x-www-form-urlencoded</code> mime
 format. for more information about html form encoding, consult the html
 <a href="specificationhttp://www.w3.org/tr/html4/">specification</a>.
用于html表单编码的工具类,这个类含有将字符串编码为application/x-www-form-urlencoded这样
mime格式的方法。关于html表单编码的更多细节,查阅html规范。
 <p>
 when encoding a string, the following rules apply:
当对字符串编码时,遵循以下规则:
 <p>
 <ul>
 <li>the alphanumeric characters "<code>a</code>" through
     "<code>z</code>", "<code>a</code>" through
     "<code>z</code>" and "<code>0</code>"
     through "<code>9</code>" remain the same.
     字母数字的字符,a-z,a-z,0-9保持不变。
 <li>the special characters "<code>.</code>",
     "<code>-</code>", "<code>*</code>", and
     "<code>_</code>" remain the same.
     特别字符.,-,*和_保持不变。
 <li>the space character "<code> </code>" is
     converted into a plus sign "<code>+</code>".
     空格字符被转换成+号。
 <li>all other characters are unsafe and are first converted into
     one or more bytes using some encoding scheme. then each byte is
     represented by the 3-character string
     "<code>%<i>xy</i></code>", where <i>xy</i> is the
     two-digit hexadecimal representation of the byte.
     the recommended encoding scheme to use is utf-8. however,
     for compatibility reasons, if an encoding is not specified,
     then the default encoding of the platform is used.
     其他所有的字符都是不安全的,首先按照编码规范转换成一个或更多的字节。每一个字节被表示成
     3字符的字符串%xy。xy是该字节的两个十六进制位表示,推荐的编码规范是utf-8。
     然而,出于兼容性考虑,如果编码没有被指定,那么默认平台所使用的编码。
 </ul>

<p>
 for example using utf-8 as the encoding scheme the string "the
 string &#252;@foo-bar" would get converted to
 "the+string+%c3%bc%40foo-bar" because in utf-8 the character
 &#252; is encoded as two bytes c3 (hex) and bc (hex), and the
 character @ is encoded as one byte 40 (hex).
 以utf-8编码举例,字符串“the string ü@foo-bar”将被转换成“the+string+%c3%bc%40foo-bar”,
 因为在utf-8中,字符ü被编码成c3(16进制)和bc(16进制),字符@被编码成一个字节40(16进制)。
<p>

<p>
<dl>
<dt><b>since:</b></dt>
  <dd>jdk1.0</dd>
</dl>
<hr>

<p>
<!-- ======== nested class summary ======== -->


<!-- =========== field summary =========== -->

<!-- ======== constructor summary ======== -->

<!-- ========== method summary =========== -->
<a name="method_summary"><!-- --></a>
<table border="1" width="100%" cellpadding="3" cellspacing="0" summary="">
<tr bgcolor="#ccccff" class="tableheadingcolor">
<td colspan=2><font size="+2">
<b>method summary</b></font></td>
</tr>
<tr bgcolor="white" class="tablerowcolor">
<td align="right" valign="top" width="1%"><font size="-1">
<code>static <a href="../../java/lang/string.html" title="class in java.lang">string</a></code></font></td>
<td><code><b><a href="../../java/net/urlencoder.html#encode(java.lang.string)">encode</a></b>(<a href="../../java/lang/string.html" title="class in java.lang">string</a> s)</code>

<br>
          <b>deprecated.</b> <i>the resulting string may vary depending on the platforms
             default encoding. instead, use the encode(string,string)
             method to specify the encoding.
             结果字符串可能根据平台默认编码而改动。代之以使用encode(string,string)方法来指定编码。</i></td>
</tr>
<tr bgcolor="white" class="tablerowcolor">
<td align="right" valign="top" width="1%"><font size="-1">
<code>static <a href="../../java/lang/string.html" title="class in java.lang">string</a></code></font></td>
<td><code><b><a href="../../java/net/urlencoder.html#encode(java.lang.string, java.lang.string)">encode</a></b>(<a href="../../java/lang/string.html" title="class in java.lang">string</a> s,
       <a href="../../java/lang/string.html" title="class in java.lang">string</a> enc)</code>

<br>
          translates a string into <code>application/x-www-form-urlencoded</code>
 format using a specific encoding scheme.
 使用指定的编码规范将字符串转换成application/x-www-form-urlencoded格式。</td>
</tr>
</table>
 <a name="methods_inherited_from_class_java.lang.object"><!-- --></a>
<table border="1" width="100%" cellpadding="3" cellspacing="0" summary="">
<tr bgcolor="#eeeeff" class="tablesubheadingcolor">
<td><b>methods inherited from class java.lang.<a href="../../java/lang/object.html" title="class in java.lang">object</a></b></td>
</tr>
<tr bgcolor="white" class="tablerowcolor">
<td><code><a href="../../java/lang/object.html#clone()">clone</a>, <a href="../../java/lang/object.html#equals(java.lang.object)">equals</a>, <a href="../../java/lang/object.html#finalize()">finalize</a>, <a href="../../java/lang/object.html#getclass()">getclass</a>, <a href="../../java/lang/object.html#hashcode()">hashcode</a>, <a href="../../java/lang/object.html#notify()">notify</a>, <a href="../../java/lang/object.html#notifyall()">notifyall</a>, <a href="../../java/lang/object.html#tostring()">tostring</a>, <a href="../../java/lang/object.html#wait()">wait</a>, <a href="../../java/lang/object.html#wait(long)">wait</a>, <a href="../../java/lang/object.html#wait(long, int)">wait</a></code></td>
</tr>
</table>
 
<p>

<!-- ============ field detail =========== -->

<!-- ========= constructor detail ======== -->

<!-- ============ method detail ========== -->
<a name="method_detail"><!-- --></a>
<table border="1" width="100%" cellpadding="3" cellspacing="0" summary="">
<tr bgcolor="#ccccff" class="tableheadingcolor">
<td colspan=1><font size="+2">
<b>method detail</b></font></td>
</tr>
</table>

<a name="encode(java.lang.string)"><!-- --></a><h3>
encode</h3>
<pre>
public static <a href="../../java/lang/string.html" title="class in java.lang">string</a> <b>encode</b>(<a href="../../java/lang/string.html" title="class in java.lang">string</a> s)</pre>
<dl>
<dd><b>deprecated.</b> <i>the resulting string may vary depending on the platforms
             default encoding. instead, use the encode(string,string)
             method to specify the encoding.
             结果字符串可能根据平台默认编码而改动。代之以使用encode(string,string)方法来指定编码。</i>
<p>
<dd>translates a string into <code>x-www-form-urlencoded</code>
 format. this method uses the platforms default encoding
 as the encoding scheme to obtain the bytes for unsafe characters.
 将字符串转换成application/x-www-form-urlencoded格式。该方法使用平台默认的编码作为编码规范来获得非安全字符的字节。
<p>
<dd><dl>
<dt><b>parameters:</b><dd><code>s</code> - <code>string</code> to be translated. 要转换的字符串。
<dt><b>returns:</b><dd>the translated <code>string</code>. 转换后的字符串。</dl>
</dd>
</dl>
<hr>

<a name="encode(java.lang.string, java.lang.string)"><!-- --></a><h3>
encode</h3>
<pre>
public static <a href="../../java/lang/string.html" title="class in java.lang">string</a> <b>encode</b>(<a href="../../java/lang/string.html" title="class in java.lang">string</a> s,
                            <a href="../../java/lang/string.html" title="class in java.lang">string</a> enc)
                     throws <a href="../../java/io/unsupportedencodingexception.html" title="class in java.io">unsupportedencodingexception</a></pre>
<dl>
<dd>translates a string into <code>application/x-www-form-urlencoded</code>
 format using a specific encoding scheme. this method uses the
 supplied encoding scheme to obtain the bytes for unsafe
 characters.
 使用指定的编码规范将字符串转换成application/x-www-form-urlencoded格式。该方法使用支持的编码规范来获得非安全字符的字节。
 <p>
 <em><strong>note:</strong> the <a href=
 "http://www.w3.org/tr/html40/appendix/notes.html#non-ascii-chars">
 world wide web consortium recommendation</a> states that
 utf-8 should be used. not doing so may introduce
 incompatibilites.</em>
 world wide web consortium recommendation声明应该使用utf-8,不这样做可能造成不兼容。
<p>
<dd><dl>
<dt><b>parameters:</b><dd><code>s</code> - <code>string</code> to be translated. 要转换的字符串。<dd><code>enc</code> - the name of a supported
    <a href="../lang/package-summary.html#charenc">character
    encoding</a>. 支持的字符编码名称。
<dt><b>returns:</b><dd>the translated <code>string</code>. 转换后的字符串。
<dt><b>throws:</b>
<dd><code><a href="../../java/io/unsupportedencodingexception.html" title="class in java.io">unsupportedencodingexception</a></code> - if the named encoding is not supported
如果不支持指定名称的编码抛出<dt><b>since:</b></dt>
  <dd>1.4</dd>
<dt><b>see also:</b><dd><a href="../../java/net/urldecoder.html#decode(java.lang.string, java.lang.string)"><code>urldecoder.decode(java.lang.string, java.lang.string)</code></a></dl>
</dd>
</dl>
<!-- ========= end of class data ========= -->
<hr>


<!-- ======= start of bottom navbar ====== -->
<a name="navbar_bottom"><!-- --></a>
<a href="#skip-navbar_bottom" title="skip navigation links"></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0" summary="">
<tr>
<td colspan=3 bgcolor="#eeeeff" class="navbarcell1">
<a name="navbar_bottom_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3" summary="">
  <tr align="center" valign="top">
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="../../overview-summary.html"><font class="navbarfont1"><b>overview</b></font></a> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="package-summary.html"><font class="navbarfont1"><b>package</b></font></a> </td>
  <td bgcolor="#ffffff" class="navbarcell1rev">  <font class="navbarfont1rev"><b>class</b></font> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="class-use/urlencoder.html"><font class="navbarfont1"><b>use</b></font></a> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="package-tree.html"><font class="navbarfont1"><b>tree</b></font></a> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="../../deprecated-list.html"><font class="navbarfont1"><b>deprecated</b></font></a> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="../../index-files/index-1.html"><font class="navbarfont1"><b>index</b></font></a> </td>
  <td bgcolor="#eeeeff" class="navbarcell1">    <a href="../../help-doc.html"><font class="navbarfont1"><b>help</b></font></a> </td>
  </tr>
</table>
</td>
<td align="right" valign="top" rowspan=3><em>
<b>java<sup><font size=-2>tm</font></sup> 2 platform<br>std. ed. v1.4.2</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="navbarcell2"><font size="-2">
 <a href="../../java/net/urldecoder.html" title="class in java.net"><b>prev class</b></a>
 <a href="../../java/net/urlstreamhandler.html" title="class in java.net"><b>next class</b></a></font></td>
<td bgcolor="white" class="navbarcell2"><font size="-2">
  <a href="../../index.html" target="_top"><b>frames</b></a>  
 <a href="urlencoder.html" target="_top"><b>no frames</b></a>  
 <script type="text/javascript">
  <!--
  if(window==top) {
    document.writeln(<a href="../../allclasses-noframe.html"><b>all classes</b></a>);
  }
  //-->
</script>
<noscript>
  <a href="../../allclasses-noframe.html"><b>all classes</b></a>
</noscript>

</font></td>
</tr>
<tr>
<td valign="top" class="navbarcell3"><font size="-2">
  summary: nested | field | constr | <a href="#method_summary">method</a></font></td>
<td valign="top" class="navbarcell3"><font size="-2">
detail: field | constr | <a href="#method_detail">method</a></font></td>
</tr>
</table>
<a name="skip-navbar_bottom"></a>
<!-- ======== end of bottom navbar ======= -->

<hr>
<font size="-1"><a href="submit>http://java.sun.com/cgi-bin/bugreport.cgi">submit a bug or feature</a><br>for further api reference and developer documentation, see <a href="../../../relnotes/devdocs-vs-specs.html">java 2 sdk se developer documentation</a>. that documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>copyright 2003 sun microsystems, inc. all rights reserved. use is subject to <a href="../../../relnotes/license.html">license terms</a>. also see the <a href="documentation>http://java.sun.com/docs/redist.html">documentation redistribution policy</a>.</font>
</body>
</html>


喜欢0 评分0
游客

返回顶部