linlinyu

          linlinyu
          posts - 0, comments - 4, trackbacks - 0, articles - 15

          struts2 輸出xml格式內(nèi)容

          Posted on 2007-12-20 23:04 linlin yu 閱讀(1814) 評(píng)論(1)  編輯  收藏 所屬分類: java
          1,配置文件
          <?xml version="1.0" encoding="UTF-8" ?>
          <!DOCTYPE struts PUBLIC
                  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                  "http://struts.apache.org/dtds/struts-2.0.dtd"
          >
          <struts>
              
          <package name="example" namespace="/example"
                  extends
          ="struts-default">
                  
          <action name="outputXml"  method="outxml" class="example.OutputXml">
                      
          <result name="xmlMessage" type="plaintext"></result>
                  
          </action>
              
          </package>
          </struts>

          2,java代碼
          package example;

          import java.io.PrintWriter;

          import javax.servlet.http.HttpServletResponse;

          import org.apache.struts2.ServletActionContext;

          import com.opensymphony.xwork2.ActionSupport;

          public class OutputXml extends ActionSupport {
              
          public void outxml() throws Exception {
                  HttpServletResponse response 
          = ServletActionContext.getResponse();
                  response.setContentType(
          "text/xml ");
                  PrintWriter pw 
          = response.getWriter();
                  pw.print(
          "<cc>cccccc</cc>");
              }

          }

          Feedback

          # re: struts2 輸出xml格式內(nèi)容  回復(fù)  更多評(píng)論   

          2009-09-14 11:55 by lw
          多謝了,挺有用的。

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 张家口市| 延津县| 涞源县| 东海县| 都江堰市| 桐庐县| 宜君县| 克拉玛依市| 海口市| 兴隆县| 桂阳县| 大厂| 东丰县| 博客| 绩溪县| 加查县| 龙岩市| 遂溪县| 任丘市| 云梦县| 滦南县| 太谷县| 文水县| 濉溪县| 铁岭县| 铁岭市| 洛阳市| 利津县| 桐柏县| 青阳县| 西华县| 长阳| 会理县| 满洲里市| 木兰县| 盐池县| 荥阳市| 贞丰县| 竹北市| 开平市| 兴山县|