jspÎļþµÄÉÏ´«ºÍÏÂÔزÙ×÷´úÂë
jspÎļþÉÏ´«ºÍÏÂÔØ
package net.jspcn.tool;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*
* Title: ÎļþÉÏ´«Àà
* Description: ¼ÈÄܶÔÎļþ½øÐÐÉÏ´«,ÓÖÄÜÈ¡µÃÊäÈë¿òµÄÖµ,×î¶à¿ÉͬʱÉÏ´«255¸öÎļþ
* Copyright: Copyright (c) 2002
* Company: Tekson
* @author ĪÇí
* @version 1.0
*/
public class UploadBean {
private String[] sourceFile = new String[255]; //Ô´ÎļþÃû
private String[] suffix = new String[255]; //Îļþºó׺Ãû
private String canSuffix = ".gif.jpg.jpeg.png"; //¿ÉÉÏ´«µÄÎļþºó׺Ãû
private String objectPath = "c:/"; //Ä¿±êÎļþĿ¼
private String[] objectFileName = new String[255]; //Ä¿±êÎļþÃû
private ServletInputStream sis = null; //ÊäÈëÁ÷
private String[] description = new String[255]; //ÃèÊö״̬
private long size = 100 * 1024; //ÏÞÖÆ´óС
private int count = 0; //ÒÑ´«ÊäÎļþÊýÄ¿
private byte[] b = new byte[4096]; //×Ö½ÚÁ÷´æ·ÅÊý×é
private boolean successful = true;
private Hashtable fields = new Hashtable();
public UploadBean() {
}
//ÉèÖÃÉÏ´«ÎļþµÄºó׺Ãû
public void setSuffix(String canSuffix) {
this.canSuffix = canSuffix;
}
//ÉèÖÃÎļþ±£´æ·¾¶
public void setObjectPath(String objectPath) {
this.objectPath = objectPath;
}
//ÉèÖÃÎļþ±£´æ·¾¶
public void setSize(long maxSize) {
this.size = maxSize;
}
//ÎļþÉÏ´«´¦Àí³ÌÐò
public void setSourceFile(HttpServletRequest request) throws IOException {
sis = request.getInputStream();
int a = 0;
int k = 0;
String s = "";
while ( (a = sis.readLine(b, 0, b.length)) != -1) {
s = new String(b, 0, a);
if ( (k = s.indexOf("filename=\"")) != -1) {
// È¡µÃÎļþÊý¾Ý
s = s.substring(k + 10);
k = s.indexOf("\"");
s = s.substring(0, k);
sourceFile[count] = s;
k = s.lastIndexOf(".");
suffix[count] = s.substring(k + 1);
if (canTransfer(count)) {
transferFile(count);
}
++count;
} else if ( (k = s.indexOf("name=\"")) != -1) {
// ÆÕͨ±íµ¥ÊäÈëÔªËØ£¬»ñÈ¡ÊäÈëÔªËØÃû×Ö
String fieldName = s.substring(k+6, s.length()-3);
sis.readLine(b, 0, b.length);
Ïà¹ØÎĵµ£º
DouyuÊÇÒ»ÖÖÍêÈ«²ÉÈ¡JavaÓïÑÔ¿ª·¢µÄ¡¢ÔË×÷ÓÚJVMÒÔÉϵÄÐÂʽ»ù´¡¿ª·¢Æ½Ì¨¡£
ÔÚweb²ã£¬DouyuÍêÈ«ÒÅÆúÁËJSP/Servlet£¬
ÔÚÊý¾Ý¿â·ÃÎʲ㣬Douyu²»ÒÀÀµÓÚÈκÎORM(¶ÔÏñ¹ØϵÕÕÉä)¹¹¼Ü(ÈçHibernate)¡£
Douyu½«JavaÓïÑÔ±àÒëÆ÷¡¢Http·þÎñÆ÷¡¢MVCÔ²Âúµ÷ÕûÔÚÒ»Æð£¬
²îµã¶ù¶ÒÏÖÁËORMÈ«×Ô¶¯»¯£¬Í¬Ê±ÔÚJavaÓïÑÔ²ãÃæÒý³öÁËȨÏÞÖ ......
̽Ë÷Èí¼þ¹¤×÷ÊÒ³¤ÆÚרҵ³Ð½ÓÖÐСÐÍÉÌÒµÈí¼þ»òÍøÕ¾£¬×îÓŻݵļ۸ñºÍ¸ßÖÊÁ¿µÄ·þÎñÆÚ´ýÄúµÄ»Ý¹Ë£¡
±¾¹¤×÷ÊÒ³Ð½Ó JSP ASP VB PB LotusNotes µÈÓïÑÔÒªÇóµÄÓ¦ÓÃϵͳ¿ª·¢ÒµÎñ
java jspʵսԴ³ÌÐò´úÂë:
......
Ê×ÏÈ,˵һÏÂ301Öض¨ÏòµÄÒâÒåÓë×÷ÓÃ(ÍøÉÏÕÒµÄÏà¹Ø×ÊÁÏ)
ÆäʵÕâ¾ÍÉæ¼°µ½ÁËSEOµÄ֪ʶ¡£
ʲôÊÇ301תÏò£¿
´ÓËÑË÷ÒýÇæÓÅ»¯½Ç¶È³ö·¢£¬301Öض¨ÏòÊÇÍøÖ·Öض¨Ïò×îΪ¿ÉÐеÄÒ»ÖÖ°ì·¨¡£µ±ÍøÕ¾µÄÓòÃû·¢Éú±ä¸üºó£¬ËÑË÷ÒýÇæÖ»¶ÔÐÂÍøÖ·½øÐÐË÷Òý£¬Í¬Ê±ÓÖ»á°Ñ¾ÉµØÖ·ÏÂÔÓеÄÍⲿÁ´½ÓÈçÊýתÒƵ½ÐµØÖ·Ï£¬´Ó¶ø²»»áÈÃÍøÕ¾µÄÅÅÃûÒòΪÍøÖ ......
ºÜ¾ÃûÓÐÓÃMysqlÁË£¬·¢ÏÖССµÄʱ¼äÎÊÌâÒ²Óöµ½²»ÉÙÂé·³£¬ºÇºÇ
ËùÒÔ×ܽáһϣº
µÚÒ»ÖÖ:
Date time= new java.sql.Date(new java.util.Date().getTime());
µÚ¶þÖÖ:
java ÓÃPreparedStatementÀ´setDate,ÓÃÎʺŵÄÐÎʽ¸øÈÕÆÚÎʺŸ³Öµ
pstmt.setTimestamp(8, new Timestamp(System.currentTimeMillis()));
pst ......