Jsp ÏÂÔØÔ¶³ÌÎļþÖÁ·þÎñÆ÷
ÎÒÊÇÔÚÒÔÏÂÕâÁ½ÖÖÇé¿öÏÂʹÓõ½Õâ¸öÎļþµÄ£º
µ±ÄãÐèÒªÏò·þÎñÆ÷ÉÏ´«Ò»¸öÎļþ£¬µ«ÊÇÕâ¸öÎļþ²¢²»ÔÚÄãµÄ±¾»úÉÏ£¬¶øÇÒÔÚÁíһ̨·þÎñÆ÷ÉÏ£¬µ«ÊÇÄãÓÖûÓб¾Ì¨·þÎñÆ÷µÄÔ¶³Ì×ÀÃæµÄȨÏÞÈÃËüÈ¥ÏÂÔØÄǸöÎļþ£¬ÕâʱÄã¾Í¿ÉÒÔʹÓôËÎļþÈ¥ÏÂÔØ¡£
¶þ¾ÍÊÇÄ¿±ê·þÎñÆ÷µÄÉÏ´«Ëٶȷdz£µÄÂý£¬ÓÚÊÇÎÒ½«ÎļþÏÈ´«µ½ÁËÁíһ̨ÉÏ´«ËٶȽϿìµÄ·þÎñÆ÷ÉÏ£¬È»ºóÈÃÄ¿±ê·þÎñÆ÷ÀûÓÃÕâ¸öÎļþÈ¥ÄÇ̨ËٶȽϿìµÄ·þÎñÆ÷ÏÂÔØ¡£¡£
¼ÇµÃÒÔÇ°µÄºÚ¿ÍÔÓÖ¾ÉÏ×ÜÊÇд×ÅÄÇȺÈËÃÇÔÚÉÏ´«Îļþµ½ÒªÈëÇֵķþÎñÆ÷µÄʱºò¾ÍÊÇÀûÓõÄÀàËƵķ½·¨¡£Ö»²»¹ýÓõÄÊÇVBS¾Ó¶à¡£
ÏÂÃæÁ½¸ö¶¼¿ÉÒÔÓ㬾ÍÊÇÏÔʾµÄЧ¹û²»Ò»Ñù¡£¡£
01.<%@page pageEncoding="utf-8" import="java.io.*,java.net.*"%>
02.<HTML>
03.<HEAD>
04.<SCRIPT TYPE="text/javascript">
05. var dataSize = 0;
06. function update(total) {
07. document.body.innerHTML = "ÒÑÏÂÔØ"+total+"/"+dataSize+"×Ö½Ú£¡";
08. }
09.</SCRIPT>
10.</HEAD>
11.<BODY>
12.<%
13.try {
14. String downFileUrl = request.getParameter("url"); //ÒªÏÂÔصÄÎļþµÄURL¡£
15. String savePath = request.getParameter("savepath"); //ÒªÁí´æΪµÄ·¾¶
16. String fileName = request.getParameter("filename"); //ÒªÁí´æΪµÄÎļþÃû
17.
18. fileName = fileName != null ? fileName : downFileUrl.substring(downFileUrl.lastIndexOf("/") + 1); //È¡ÎļþÃû
19. savePath = (savePath) != null ? savePath + "/" + fileName : application.getRealPath("") + "/" + fileName; //È¡±£´æ·¾¶µÄ¾ø¶ÔµØÖ·
20.
21. URL downUrl = new URL(downFileUrl);
22. URLConnection conn = downUrl.openConnection();
23.
24. int dataSize = conn.getContentLength(); //È¡µÃÒªÏÂÔصÄÊý¾ÝµÄ³¤¶È
25. out.println("<SCRIPT>dataSize = "+dataSize+";</SCRIPT>");
26.
27. BufferedInputStream in = new BufferedInputStream(conn.getInputStream());
28. BufferedOutputStream outS = new BufferedOutputStream(new FileOutputStream(new File(savePath)));
29.
30. byte[] data = new byte[1024];
31. long total = 0;
32.
Ïà¹ØÎĵµ£º
½øÈëMyEclipse6.XÏÂ
Ð޸ģºeclipse.ini Îļþ
-Duser.language=en
¸Ä³É
-Duser.language=zh
µ¯³öÌáʾ£ºCtrl+"/"
dtd ÃüÃû¿Õ¼äµÄÌáʾÐÅÏ¢
window-->Preference-->xml-->XML Catalog-->add
Location :sql-map-2.dtd
key type :pubic ID
key:-//ibatis.apache.org//DTD SQL Map 2.0//EN (XMLÎļþÃüÃû¿Õ¼ ......
ÔÚJava web¿ª·¢Öг£»áʹÓõ½¹¦ÄÜÇ¿´óµÄ¹ýÂËÆ÷£¬Ëû±Ï¾¹ÄܸøÎÒÃÇ´øÀ´ºÜ´óµÄ·½±ã£¬µ«ÊÇÕë¶Ô¹ýÂ˵Ä×ÊÔ´ÎÒÃÇÐèÒªÏêϸµÄÁ˽âËûÃÇÔÚweb.xmlÖеÄÅäÖÃÐÅÏ¢¡£Õâ¸ö¸ù¾Ý¼¸ÖÖ³£ÓõIJ»Í¬Çé¿ö½øÐÐÁË×ܽ᣺
1¡£Èç¹ûÒªÓ³Éä¹ýÂËÓ¦ÓóÌÐòÖÐËùÓÐ×ÊÔ´£º
<filter>
<filter-name>loggerfilter</filter-name>
<f ......
JSTL <c:out value="${EL}">²»ÄÜÕýÈ·Êä³öµÄÎÊÌâ
ÓÉÓÚJsp2.0Ïòºó¼æÈݵÄÌØÐÔ£¬ µ±Óöµ½Ê¹ÓÃJsp 1.2£¨Servlet v2.3£©µÄÍøվʱ»áĬÈϵĽûÓÃJSP2.0 EL£¬ËùÒÔµ¼ÖÂc:out²»ÄÜÕýÈ·Êä³ö¡£
£¨ÕâÀï×¢ÒâJsp 1.2½ûÓÃJSP2.0µÄEL£¬¶øÊÇȥʹÓÃJSTL 1.0 taglibÈ¥½âÎöEL¡£ËùÒÔʹÓÃJSP 1.2+JSTL 1.0²»»á³öÎÊÌ⣬
¶øʹÓÃÁËJSP 1.2+JSTL 1 ......
ij¸öjspÒ³ÃæµÚÒ»´ÎÔËÐÐʱ£¬tomcat»á°ÑËü±àÒë³ÉjavaÎļþ£¬ÒÔºóÔËÐиÃÒ³Ãæʱ£¬tomcat»á¶Ô±ÈjspºÍjavaÎļþµÄÈÕÆÚ£¬Èç¹ûСÓÚ»òµÈÓÚjavaÎļþÔòÈÏΪÊÇjavaÎļþÊÇ×îеÄ,¾ÍÖ±½ÓÔËÐÐÁË
tomcat ÏÂÓиöworkĿ¼,ÀïÃæÓÐÄãËùÓÐÓ¦ÓÃ./tomcat6/work/Catalina/localhost¡£ËùÓеÄjspÒ³ÃæÊ×ÏÈÒª±»±àÒë³É.class
ÔÚÔËÐÐʱ,tomcat»áÖ±½Ó¼ÓÔØcl ......
1. pageEncoding: Ö»ÊÇÖ¸Ã÷ÁË JSP Ò³Ãæ±¾ÉíµÄ±àÂë¸ñʽ£¬¸úÒ³ÃæÏÔʾµÄ±àÂëûÓйØϵ;
ÈÝÆ÷ÔÚ¶ÁÈ¡(Îļþ)»òÕß(Êý¾Ý¿â)»òÕß(×Ö·û´®³£Á¿)ʱ½«Æðת»¯ÎªÄÚ²¿Ê¹ÓÃµÄ Unicode,¶øÒ³ÃæÏÔʾµÄʱºò½«
ÄÚ²¿µÄUnicodeת»»ÎªcontentTypeÖ¸¶¨µÄ±àÂëºóÏÔʾҳÃæÄÚÈÝ;
Èç¹ûpageEnco ......