使用 aspx 页面返回 xml 格式的值时,需要注意写法
解决了,是1楼说的方法,不能写成
context.Response.ContentType = "xml";
必须要是
context.Response.ContentType = "text/xml";
就OK了~
实例:
Response.ContentType = "text/xml";
Page.Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
Page.Response.Write("<data>");
Page.Response.Write("<pets>");
Page.Response.Write("<pet>猫</pet>");
Page.Response.Write("<pet>狗</pet>");
Page.Response.Write("<pet>鱼</pet>");
Page.Response.Write("</pets>");
Page.Response.Write("</data>");
相关文档:
/// <summary>
/// 收到的XML转成dataset型
/// </summary>
/// <param name="xmlData"></param>
/// ......
首先写一个html页面userxmlajax.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户校验ajax实例</title>
&nbs ......
首先写一个html userxmljquery.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户校验ajax实例</title>
& ......
扩展Struts2--自定义String和XML格式的Result
struts2虽然继承了webwork优秀的MVC分离,可是有很多地方让人百思不得其解!最让人离谱的是,返回的结果集中居然没有
String,xml这两种非常常用的类型。还是自己动手,丰衣足食:
第一种方式:使用“PlainText Result”
& ......