您的位置:首页 > 编程语言 > Java开发

用struts2给android客户端发送xml数据

2012-03-31 15:16 169 查看
一、严格按照xml文件的格式书写,防止struts标签影响到xml的格式:

<?xml version="1.0" encoding="UTF-8"?><%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8"%><%@taglib uri="/struts-tags" prefix="s"%>

<videos><s:iterator value="#request.videos" id="video" >

<video id="<s:property value="id"/>">

<name><s:property value="name"></s:property></name>

<time><s:property value="time"></s:property></time>

</video></s:iterator>

</videos>

注意:1.<?xml version="1.0" encoding="UTF-8"?>必须是文件的开头一句,前面不要有空格,是xml文件的规定。

2.注意文档的格式,<videos><s:iterator value="#request.videos" id="video" >这两段间不要换行,防止以后解析出现不必要的麻烦

二、下面是浏览器看到的效果:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<videos>

<video id="59">

<name>情歌</name>

<time>2:30</time>

</video>

<video id="19">

<name>老男孩</name>

<time>2:50</time>

</video>

<video id="39">

<name>那些年</name>

<time>3:30</time>

</video>

</videos>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: