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"); %> |