yunye 的 JavaBlog

          @see codemouse

          統計

          留言簿(1)

          閱讀排行榜

          評論排行榜

          jsp超級鏈接實現"目標另存為"功能

          jsp:


          <% @?page?language = " java " ?contentType = " text/html;?charset=GB18030 "
          ????pageEncoding
          = " GB18030 "
          %>
          <! DOCTYPE?html?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN"?"http://www.w3.org/TR/html4/loose.dtd" >
          < html >
          < head >
          < meta? http-equiv ="Content-Type" ?content ="text/html;?charset=GB18030" >
          < title > Insert?title?here </ title >
          </ head >
          < body >
          < a? href ="/test/test.do" > 1322 </ a >
          </ body >
          </ html >

          ?action:


          package ?action;

          import ?java.io.FileOutputStream;

          import ?javax.servlet.http.HttpServletRequest;
          import ?javax.servlet.http.HttpServletResponse;

          import ?org.apache.struts.action.Action;
          import ?org.apache.struts.action.ActionForm;
          import ?org.apache.struts.action.ActionForward;
          import ?org.apache.struts.action.ActionMapping;


          public ? class ?TeAction? extends ?Action? {

          ????
          public ?ActionForward?execute(ActionMapping?mapping,?ActionForm?form,
          ????????????HttpServletRequest?request,?HttpServletResponse?response)?
          throws ?Exception? {
          ????????
          // ?TODO?Auto-generated?method?stub
          ????
          ?????????StringBuilder?sb?
          = ? new ?StringBuilder();
          ?????????sb.append(
          " 1 " );
          ?????????response.addHeader(
          " Content-Disposition " ,? " attachment;?filename=test.txt " );?
          ?????????response.setContentType(
          " application/octet-stream " );?
          ?????????response.setCharacterEncoding(
          " GB2312 " );?
          ?????????response.getWriter().write(sb.toString());?
          ?????????response.flushBuffer();


          ????????
          return ? null ;
          ????}

          }

          posted on 2008-03-22 01:40 yunye 閱讀(920) 評論(1)  編輯  收藏 所屬分類: jsp

          評論

          # re: jsp超級鏈接實現"目標另存為"功能 [未登錄] 2012-05-15 10:26 李四

          目標另存為  回復  更多評論   

          主站蜘蛛池模板: 海原县| 陆良县| 宜良县| 镶黄旗| 尚义县| 治多县| 黄石市| 日喀则市| 大同市| 肥乡县| 昌黎县| 佳木斯市| 巴中市| 泸定县| 乐至县| 钟祥市| 马龙县| 炎陵县| 监利县| 卢湾区| 维西| 苍梧县| 桂林市| 永丰县| 拜泉县| 库尔勒市| 辽中县| 水城县| 锡林浩特市| 浦北县| 榆社县| 得荣县| 霍林郭勒市| 乐至县| 涿鹿县| 瑞昌市| 信阳市| 绥阳县| 大关县| 油尖旺区| 临漳县|