JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Servlet/JSP 討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 page指令:contentType VS. pageEncoding [精華]
browser

戀香

版主

發文: 3570
積分: 1
於 2003-10-31 00:32 user profilesend a private message to usersend email to browserreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
JSP 2.0 的 page 指令中有兩個屬性 contentType 和 pageEncoding
我翻了 JSP 2.0 Spec 和 SCWCD Exam Study Kit
還是看不太懂它們兩者之間的差異
所以上來請教一下各位

我先列出 SCWCD Exam Study Kit 的敘述:

The contentType attribute specifies the MIME type and character encoding of the
output. The default value of the MIME type is text/html; the default value of the
character encoding is ISO-8859-1. The MIME type and character encoding are
separated by a semicolon, as shown here:
1
<%@ page contentType="text/html;charset=ISO-8859-1" %>

This is equivalent to writing the following line in a servlet:
1
response.setContentType("text/html;charset=ISO-8859-1");

The pageEncoding attribute specifies the character encoding of the JSP page. The
default value is ISO-8859-1. The following line illustrates the syntax:
1
<%@ page pageEncoding="ISO-8859-1" %>


下面是JSP 2.0 Spec 中 contentType 和 pageEncoding 的敘述:

contentType

Defines the MIME type and the character encoding for the
response of the JSP page, and is also used in determining the
character encoding of the JSP page.
Values are either of the form “TYPE” or “TYPE;charset=
CHARSET”with an optional white space after the “;”.
“TYPE” is a MIME type, see the IANA registry at
http://www.iana.org/assignments/media-types/index.html
for useful values. “CHARSET”, if present, must be the IANA name for
a character encoding.
The default value for “TYPE” is “text/html” for JSP pages in
standard syntax, or “text/xml” for JSP documents in XML
syntax. If “CHARSET” is not specified, the response
character encoding is determined as described in
Section JSP.4.2, “Response Character Encoding”.
See Chapter JSP.4 for complete details on character
encodings.

pageEncoding

Describes the character encoding for the JSP page. The value
is of the form “CHARSET”, which must be the IANA name
for a character encoding. For JSP pages in standard syntax,
the character encoding for the JSP page is the charset given
by the pageEncoding attriute if it is present, otherwise the
charset given by the contentType attribute if it is present,
otherwise “ISO-8859-1”.
For JSP documents in XML syntax, the character encoding
for the JSP page is determined as described in section 4.3.3
and appendix F.1 of the XML specification. The pageEncoding
attribute is not needed for such documents. It is a
translation-time error if a document names different
encodings in its XML prolog / text declaration and in the
pageEncoding attribute. The corresponding JSP
configuration element is page-encoding (see
Section JSP.3.3.4, “Declaring Page Encodings”).
See Chapter JSP.4 for complete details on character
encodings.


browser edited on 2003-10-31 00:36
reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
31397 [精華] page指令:contentType VS. pageEncoding browser 2733 2003-10-31 00:32
23789 Re:page指令:contentType VS. pageEncoding browser 926 2003-10-31 05:07
28712 Re:page指令:contentType VS. pageEncoding akar 1681 2003-11-06 10:58
22452 Re:page指令:contentType VS. pageEncoding gucci 165 2004-03-24 23:03
21621 Re:page指令:contentType VS. pageEncoding ptk 174 2004-06-17 22:48
21431 Re:page指令:contentType VS. pageEncoding snpshu 299 2004-06-18 09:33
22875 Re:page指令:contentType VS. pageEncoding ptk 303 2004-06-18 10:43
21758 Re:page指令:contentType VS. pageEncoding simontiis 110 2004-06-24 11:18
21388 Re:page指令:contentType VS. pageEncoding hhyear 232 2004-06-29 10:02
22252 Re:page指令:contentType VS. pageEncoding lightning 552 2006-01-15 14:08
» JWorld@TW »  Servlet/JSP 討論區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8