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

JSPʵÏÖÎļþÉÏ´«

ʹÓÃRandomAccessFileÀàÌṩµÄ¹¦ÄÜÀ´ÊµÏÖÎļþÉÏ´«¡£µ±ÎÒÃÇÏë¶ÔÒ»¸öÎļþ½øÐжÁд²Ù×÷ʱ£¬¿ÉÒÔ´´½¨Ò»¸öÖ¸Ïò¸ÃÎļþµÄRandomAccessFileÁ÷¼´¿É£¬ÕâÑù¼È¿ÉÒÔ´ÓÕâ¸öÁ÷ÖжÁÈ¡Õâ¸öÎļþµÄÊý¾Ý£¬Ò²Í¨¹ýÕâ¸öÁ÷дÈëÊý¾Ý¸øÕâ¸öÎļþ¡£
ÀûÓÃJavaBean¸ºÔð½«Óû§Ñ¡ÔñµÄÎļþÉÏ´«µ½·þÎñÆ÷¡£bean¿ÉÒÔÈÃÄÚÖöÔÏórequestµ÷Ó÷½·¨getInputStream£¨£©»ñµÃÒ»¸öÊäÈëÁ÷£¬Í¨¹ýÕâ¸öÊäÈëÁ÷¶ÁÈë¿Í»§ÉÏ´«µÄÈ«²¿ÐÅÏ¢£¬°üÀ¨ÎļþµÄÄÚÈÝÒÔ¼°±íµ¥ÓòµÄÐÅÏ¢¡£bean¿ÉÒÔ´ÓÉÏ´«µÄÈ«²¿ÐÅÏ¢ÖзÖÀë³öÎļþµÄÄÚÈÝ£¬²¢±£´æÔÚ·þÎñÆ÷¶Ë¡£°´ÕÕHTTPЭÒ飬Îļþ±íµ¥Ìá½»µÄÐÅÏ¢ÖУ¬Ç°4Ðкͺó5ÐÐÊÐ±íµ¥±¾ÉíµÄÐÅÏ¢£¬Öм䲿·Ö²ÅÊÇ¿Í»§Ìá½»µÄÎļþµÄÄÚÈÝ¡£beanͨ¹ýʹÓÃRandomAccessFileÁ÷»ñÈ¡ÎļþµÄÄÚÈÝ£¬¼´È¥µô±íµ¥µÄÐÅÏ¢¡£Ê×ÏÈ£¬bean½«¿Í»§Ìá½»µÄÈ«²¿ÐÅÏ¢±£´æΪһ¸öÁÙʱÎļþ£¬¸ÃÎļþµÄÃû×ÖÊÇ¿Í»§µÄsession¶ÔÏóµÄid£¨²»Í¬¿Í»§µÄÕâ¸öidÊDz»Í¬µÄ£©£¬È»ºó¶ÁÈ¡¸ÃÁÙʱÎļþµÄµÚ2ÐУ¬ÕâÒ»ÐÐÖк¬Óпͻ§ÉÏ´«µÄÎļþµÄÎÄ×Ö£¬»ñÈ¡Õâ¸öÃû×Ö£¬ÔÙ»ñÈ¡µÚ4ÐнáÊøµÄλÖã¬ÒÔ¼°µ¹ÊýµÚ6ÐеĽáÊøλÖã¬ÒòΪÕâÁ½¸öλÖÃÖ®¼äµÄÄÚÈÝÊÇÉÏ´«ÎļþµÄÄÚÈÝ£¬È»ºó½«Õⲿ·ÖÄÚÈÝ´æÈëÎļþ£¬¸ÃÎļþµÄÃû×ֺͿͻ§ÉÏ´«µÄÎļþµÄÃû×Ö±£³ÖÒ»Ö¡£×îºóɾ³ýÁÙʱÎļþ¡£
JSPÒ³ÃæÖУº
<form action=""  method="post" enctype="multipart/form-data">
     <input type="file" name="boy" size="45"><br>
     <input type="submit" name="g" value="Ìá½»">
</form>
ÕâÑùÑ¡ÔñÎļþÌá½»ºórequest¾Í»áÓÐÎļþÁ÷ÐÅÏ¢¡£
UpFile.java
package bean;
import java.io.*;
import javax.servlet.http.*;
public class UpFile
{
HttpServletRequest request;
HttpSession session;
String upFileMessage="";

public void setRequest(HttpServletRequest request)
{
this.request = request;
}

public void setSession(HttpSession session)
{
this.session = session;
}

public String getUpFileMessage()
{
String fileName = null;
try
{
String tempFileName = (String)session.getId(); //¿Í»§µÄsessionµÄid
File f1 = new File("F:\\workspace\\testUpLoadFile\\UpFiles", tempFileName);
FileOutputStream o = new FileOutputStream(f1);
InputStream in = request.getInputStream(); //»ñÈ¡ÇëÇóµÄ×Ö½ÚÁ÷
byte b[] =


Ïà¹ØÎĵµ£º

ÈÃhtmlÒÔ¼°jspÒ³Ãæ²»±»»º´æ

¶ÔÓÚHTMÍøÒ³£¬¼ÓÈ룺
<meta HTTP-EQUIV="pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<meta HTTP-EQUIV="expires" CONTENT="0">
È»ºó£¬jspÒ³ÃæÖмÓÈ룺
<%
     response.setHeader("Cache-Control","no-store") ......

JSP¼Ü¹¹¡¢JSP¿ª·¢¹¤¾ßÓÅȱµã±È½Ï

   Ëæ׿¼ÊõµÄÈÕÐÂÔÂÒì £¬JSPµÄм¼ÊõÒ²²ã³ö²»ÇΪÁË·½Ãæ´ó¼ÒµÄѧϰÓ빤×÷£¬ÏÂÃ潫¼òµ¥µÄ½éÉÜÒ»ÏÂJSP¼Ü¹¹¡¢JSP¿ª·¢¹¤¾ß¡¢Web·þÎñÆ÷¼°Æäîñȱµã¡£
    JSP¼Ü¹¹£º
    struts£º  Struts¸úTomcat¡¢TurbineµÈÖî¶àApacheÏîÄ¿Ò»Ñù£¬ÊÇ¿ªÔ´Èí¼þ£¬ÕâÊÇËüµÄÒ»´óÓŵ㣬ʹ¿ª·¢ÕßÄܸüÉ ......

jsp(JAVA)α¾²Ì¬µÄ¾ßÌåÉèÖùý³Ì

Ç°¼¸Ì죬ºþÄÏSEOÔÚÓÃjspдһ¸öÆóÒµÕ¾³ÌÐòµÄʱºò£¬ÒòΪҪ²Î¼ÓÏîÄ¿´ð±ç¾ºÑ¡£¬ËùÒÔ¾ÍÏëΪ×Ô¼ºÐ´µÄ³ÌÐò¸ã¼¸¸öÁÁµã£¬ÒòΪ¸ãSEO¾ÃÁË£¬²»×Ô¾õ¾Í»áÏ뵽α¾²Ì¬£¬µ«ÊÇÔڰٶȲéÁËÒ»¸öÏÂÎ磬ֻ²éµ½ÁËurlrewrite¼Ü°üµÄÏÂÔصط½£¬ºÍ¼ÜÉè·½ÃæµÄÎÄÕ£¬²¢Ã»ÓÐjsp(JAVA)α¾²Ì¬µÄ¾ßÌå²Ù×÷ʾ·¶£¬ÓеÄÒ²Ö»ÊÇ£¬µ¥Ò³ÃæµÄα¾²Ì¬µÄд·¨£¬ÕâÀïÎÒ¾ÍÖØÍ· ......

js¡¢jsp´«µÝ²ÎÊýÂÒÂëÎÊÌâ½â¾ö

ÒÔÇ°ÓÐÌáµ½¹ýÂÒÂëÎÊÌ⣬×î½üÔÚʹÓÃwindow.openʱÓÖ³öÏÖ´ËÀàÎÊÌ⣬ÏÖ½â¾öÈçÏ£º
1£ºÊ¹ÓÃencodeURIComponentº¯Êý¶Ô²ÎÊý½øÐд¦Àí£¬ÀýÈ磺window.open("html.jsp?name=" + encodeUrlComponent(value)));
2£ºÐÞ¸Ätomcat·þÎñÆ÷µÄserver.xmlÎļþÌí¼Ó£ºuseBodyEncodingForURI="true"»òÕß
URIEncoding=" ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ