Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÔÚJSPÖÐÏÂÔØÎı¾Îĵµ

ͨ³££¬ÎÒÃÇÐèÒªÌṩһ¸öÎļþÏÂÔصÄʱºò£¬½öÐèÒªÒ»¸ö³¬Á´½Ó¾Í¿ÉÒÔ½â¾ö¡£
 
±ÈÈçexeÎļþ£¬Êó±ê×ó¼üµã»÷Á´½Ó¾Í»áÌáʾÄãÖ±½ÓÖ´Ðл¹ÊDZ£´æ£¬ÓÒ¼üÔò¿ÉÒÔÖ±½ÓÁí´æΪ¡£¡£¡£
 
µ«ÊÇÓÐÒ»²¿·ÖÎļþ£¬±ÈÈçtxtµÈ¿ÉÒÔÔÚä¯ÀÀÆ÷ÖÐÖ±½Ó´ò¿ªµÄÎļþ£¬ÄãÖ»ÄÜÓÃÊó±êÓÒ¼üµã»÷Á´½ÓÈ»ºóÁí´æΪµÄ·½Ê½È¥±£´æ¸ÃÎļþ£¬Èç¹ûÖ±½Óµã»÷×ó¼ü£¬¸ÃÎļþ¾ÍÔÚä¯ÀÀÆ÷Öб»´ò¿ªÁË¡£
 
ÔÚһЩÐèÇóÖУ¬ÎÒÃÇÐèÒªÈÃtxtÓµÓÐexeÎļþÀàËƵĶ¯×÷£¬¼´×ó¼üµã»÷ʱҲÈÃËüÌáʾ±£´æ»¹ÊÇ´ò¿ª¡£
 
ÍøÉϺܶàÎÄÕ¶¼Ìáµ½ÓÃjspsmartuploadÈ¥×öÕâ¼þÊÂÇ飬smartuploadµ±È»ÊǸöºÃ¶«Î÷£¬¿ÉÒÔÓõÄʱºò¾¡¹ÜÓ㬵«ÊÇËü²¢²»ÊDZØÐëµÄ£¬ÎÒÃÇÔÚjspÖпÉÒÔÖ±½ÓÉèÖÃresponseµÄHeader (Content-Disposition) À´´ïµ½Ä¿µÄ¡£ÏÂÃæÊÇÕû¸ö¹ý³Ì£º
 
1£©Ê×ÏÈÄãÒªÌṩһ¸öÏÂÔصÄÁ´½Ó£¬»òÕßbutton£¬È磺
<a href="download.jsp">ÎļþÏÂÔØ</a>
<button type="submit" onClick="window.open('download.jsp')">ÎļþÏÂÔØ</button>
×ÜÖ®£¬ÐèÒªÓÐÒ»¸ö·½·¨Ìøתµ½ÊµÏÖÎļþÏÂÔصÄjsp»òÕßservletÖС£
 
2£©ÔÚdownload.jsp£¨»òÕßʵÏÖͬÑù¹¦ÄܵÄservlet£©ÖУ¬´úÂëÈçÏ£º
<%@ page contentType="text/html;charset=gb2312"%>
<%   
     /* Ç°°ë²¿·ÖÊÇ»ñµÃserverÉÏwebcontentµÄÕæʵ·¾¶£¬
      * ÒòΪ»ñµÃÒ»¸öFileInputStream±ØÐëʹÓÃ"E:/webcontent/filename.txt"ÕâÖÖÀàÐ͵ÄÕæʵ·¾¶£¬
      * ¶ø²»ÊÇ"http://www.xxx.com/xxx/filename.txt"ÕâÖÖURLµÄÐÎʽ¡£
      * dataname ÊǾßÌåµÄÎļþÏà¶ÔÓÚwebcontentµÄ·¾¶ */
     String fullname = request.getSession().getServletContext().getRealPath("/") + dataname;
 
     // filenameÊDZ£´æʱµÄĬÈÏÎļþÃû£¬¾­ÊµÑ飬ÔÚFirefox2ºÍIE7ÖУ¬Õâ¸öÎļþÃûÊÇÓÐÓõģ¬ÔÚIE6ÖÐËƺõûʲôÓã¬ÓÐÐËȤµÄÈËÔÙÈ¥Ñо¿Ñо¿°É
     String filename = fullname.substring(fullname.lastIndexOf('/'));   
     int i = 0;  
     response.setContentType("text/plain"); 
 
     // ¹Ø¼üÊÇÉèÖÃÕâ¸öHea


Ïà¹ØÎĵµ£º

JSP±ÜÃâFormÖظ´Ìá½»µÄÈýÖÖ·½°¸

¡¡¡¡1 Javascript £¬ÉèÖÃÒ»¸ö±äÁ¿£¬Ö»ÔÊÐíÌá½»Ò»´Î¡£
¡¡¡¡#lt;script language="javascript"#gt;
¡¡¡¡ var checkSubmitFlg = false;
¡¡¡¡ function checkSubmit() {
¡¡¡¡ if (checkSubmitFlg == true) {
¡¡¡¡ return false;
¡¡¡¡ }
¡¡¡¡ checkSubmitFlg = true;
¡¡¡¡ return true;
¡¡¡¡ }
¡¡¡¡ document.ondblcli ......

JSPÎļþ

<%@ page language="java" import="kg.TestBean2;" %>
<%@ page contentType="text/html;charset=gb2312" %>
<html>
<head>
<title>HelloBean</title>
</head>
<body>
<%--
<%
kg.TestBean2 testbean=(kg.TestBean2)session.setAttribute("testbean");
if ......

jsp¿Í»§¶ËÈ¥»º´æºÍ·þÎñ¶ËÈ¥»º´æ

 
ÍøÒ³»º´æµÄ×÷ÓÃÊÇʲô£¿Ó¦¸ÃºÜÖØÒª¡£µ«ÊÇÎÒÃÇÔÚ¿ª·¢ÍøÂçÓ¦ÓõÄʱºò£¬ÍøÒ³»º´æ×ÜÊǸøÎÒÃÇÒ»ÖÖĪÃûµÄ·³ÄÕ¡£ÓÚÊǼ¸ºõÿһ¸ö¿ª·¢Õ߶¼ÊÔͼ½â¾ö¹ýÕâ¸öÎÊÌâ¡£µ±È»£¬ÎÒÒ²²»ÊǽñÌì²Å×ÅÊÖ½â¾öÕâ¸öÎÊÌâ¡£µ«ÊǽñÌìһʱÐÄѪÀ´³±£¬Ð´Ò»Æª£¬¼Ç¼һÏÂÓõ½µÄ·½·¨¡£
1.½ûÖ¹¿Í»§¶Ë»º´æÒªÔÚ<head>ÖмÓÈëÀàËÆÈçÏÂÄÚÈÝ(ÎÒµ±È»»¹Ã»Ó ......

javabeanÏò´«jsp´«Öµ

struts-config:
<action path="/articleManage" name="articleManageForm"  scope="request" type="auction.action.ArticleManageAction" validate="false">
   <forward name="atriclesList" path="/WEB-INF/publish/articleManage/atriclesList.jsp"/>
   <forward ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ