MIME類型
- application/vnd.wap.xhtml+xml
- application/xhtml+xml
- text/html
- 獲得收到的HTTP請求頭的值,接受的頭中包含客戶端代理能處理的全部MIME類型。
- 如果接受的頭的值中包含"application/vnd.wap.xhtml+xml",則設置XHTML MP的MIME類型爲"application/vnd.wap.xhtml+xml",否則如果接受的頭的值中包含"application/xhtml+xml",則設置XHTML MP的MIME類型爲"application/xhtml+xml",否則設置XHTML MP的MIME類型爲"text/html"。
String acceptHeader = request.getHeader("accept");
response.setContentType("application/vnd.wap.xhtml+xml");
else if (acceptHeader.indexOf("application/xhtml+xml") != -1)
response.setContentType("application/xhtml+xml");
else
response.setContentType("text/html");
%>
...
else if (acceptHeader.indexOf("application/xhtml+xml") != -1)
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<? xml
version = "1.0" ?> <!DOCTYPE
html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" < html
xmlns = "http://www.w3.org/1999/xhtml" > < head > < title >XHTML
MP Tutorial</ title > </ head > < body > < p >Hello
world. Welcome to our XHTML MP tutorial.</ p > </ body > </ html > <% String
acceptHeader = request.getHeader("accept"); if
(acceptHeader.indexOf("application/vnd.wap.xhtml+xml") != -1) response.setContentType("application/vnd.wap.xhtml+xml"); else
if (acceptHeader.indexOf("application/xhtml+xml") != -1) response.setContentType("application/xhtml+xml"); else response.setContentType("text/html"); %> |