¹ØÓÚjavaµÄhttpÐÒéÎļþÉÏ´«ÊµÓÃÀýÌâÒ»
¹ØÓÚjavaµÄhttpÐÒéÎļþÉÏ´«ÊµÓÃÀýÌâÒ»
(2006-07-25 16:43:56)
תÔØ
·ÖÀࣺ
java
¹ØÓÚjavaµÄhttpÐÒéÉÏ´«:(¼òµ¥ÊµÓöøÇÒ½¡×³;Ëٶȿì)
´Ë·½·¨±ÈapacheµÄÎļþÉÏ´«°ü(uploadfile1.1:¾ÍÎļþÉÏ´«¹¦ÄܶøÑÔ)Ҫǿ¶àÁË
1.Ö»ÐèÒªÒ»¸öMultipartRequest.java»ù±¾Îļþ¾ÍÐС£
2.ǰ̨htmlµÄ»ù±¾¸ñʽ
<html><body><form enctype="multipart/form-data"
method="post">
<input type="file" name="path"
size="38" />
<input type="text"
name="res_name" size="38" />
</body></html>
3.ºǫ́µ÷ÓôËÎļþ·½·¨ÈçÏÂ:
reqÊÇHttpServletRequestÀà.
try {
if
(req.getMethod().equals("POST") &&
MultipartRequest.isMultipart(req)) {
req = new
MultipartRequest(req, userId);//userIdµÇ½Óû§±êʶ
//µÃµ½ÉÏ´«Îļþ
File
upFile = ((MultipartRequest) req).getFile("path");
//µÃµ½ÉÏ´«ÎļþÃû
String
fileName = ((MultipartRequest) req).getFileName(upFile);
//µÃµ½ÉÏ´«httpµÄÖµ
req.getParameter("res_name");
//°ÑÉÏ´«Îļþ´æ·Åµ½c:/tempĿ¼ÏÂÃûΪ123.jpgµÄÎļþ
saveAs(upFile,
"c:/temp/123.jpg");
finally {
if (req instanceof
MultipartRequest) {
//Çå³ýÉÏ´«µÄÁÙʱÎļþ
((MultipartRequest) req).deleteTemporaryFile();
}
//°ÑÉÏ´«Îļþ´æ·Åµ½Ö¸¶¨µÄĿ¼ÏÂÎļþÃû
private void saveAs(File upFile, String filePath) throws
IOException {
FileInputStream fis =
null;
FileOutputStream fos =
null;
try {
fis = new
FileInputStream(upFile);
int len =
fis.available();
byte[] by =
new byte[len];
fis.read(by);
fos = new
FileOutputStream(filePath);
fos.write(by);
}
finally {
&n
Ïà¹ØÎĵµ£º
1. ÏÈдһ¸öSingletonµÄclass
package stone;
public class Singleton {
private static Singleton instance;
private Singleton() {}
public static Singleton getInstance(){
if(instance==null)
&n ......
×÷Õß: ØýÃû, ¡¡³ö´¦:ITר¼ÒÍø,¡¡ÔðÈαà¼: лåûåû,¡¡2010-05-10 13:00
Java °ÑÄÚ´æ»®·Ö³ÉÁ½ÖÖ£ºÒ»ÖÖÊÇÕ»Äڴ棬ÁíÒ»ÖÖÊǶÑÄÚ´æ¡£ÔÚº¯ÊýÖж¨ÒåµÄһЩ»ù±¾ÀàÐ͵ıäÁ¿ºÍ¶ÔÏóµÄÒýÓñäÁ¿¶¼ÊÇÔÚº¯ÊýµÄÕ»ÄÚ´æÖзÖÅ䣬µ±ÔÚÒ»¶Î´úÂë¿é¶¨ÒåÒ»¸ö±äÁ¿Ê±£¬Java ¾ÍÔÚÕ»ÖÐΪÕâ¸ö±äÁ¿·ÖÅäÄÚ´æ¿Õ¼ä£¬µ±³¬¹ý±äÁ¿µÄ×÷ÓÃÓòºó£¬Java »á×Ô¶¯Êͷŵô ......
1. ¼òµ¥¹¤³§:
(1). ´´½¨Êä³ö(Output)½Ó¿Ú
package stone;
public interface Output {
public int MAX_COUNT =10; // ×î¶à¿É´òÓ¡¶àÉÙÌõ¼Ç¼
public void show(); ......
LuceneÊÇÒ»¸ö»ùÓÚJavaµÄÈ«ÎÄË÷Òý¹¤¾ß°ü¡£
»ùÓÚJavaµÄÈ«ÎÄË÷ÒýÒýÇæLucene¼ò½é£º¹ØÓÚ×÷ÕߺÍLuceneµÄÀúÊ·
È«ÎļìË÷µÄʵÏÖ£ºLueneÈ«ÎÄË÷ÒýºÍÊý¾Ý¿âË÷ÒýµÄ±È½Ï
ÖÐÎÄÇзִʻúÖƼò½é£º»ùÓÚ´Ê¿âºÍ×Ô¶¯ÇзִÊËã·¨µÄ±È½Ï
¾ßÌåµÄ°²×°ºÍʹÓüò½é£ºÏµÍ³½á¹¹½éÉܺÍÑÝʾ
Hacking Lucene£º¼ò»¯µÄ²éѯ·ÖÎöÆ÷£¬É¾³ýµÄʵÏÖ£¬¶¨ÖƵÄÅÅÐò£ ......
±¾ÎÄÖ÷Ҫ̸һÏÂÃÜÂëѧÖеļÓÃܺÍÊý×ÖÇ©Ãû£¬ÒÔ¼°ÆäÔÚjavaÖÐÈçºÎ½øÐÐʹÓ᣶ÔÃÜÂëѧÓÐÐËȤµÄ»ï°é£¬ÍƼö¿´Bruce SchneierµÄÖø×÷£ºApplied Crypotography.ÔÚjdk1.5µÄ·¢Ðа汾Öа²È«ÐÔ·½ÃæÓÐÁ˺ܴóµÄ¸Ä½ø£¬Ò²ÌṩÁ˶ÔRSAËã·¨µÄÖ±½ÓÖ§³Ö£¬ÏÖÔÚÎÒÃÇ´ÓʵÀýÈëÊÖ½â¾öÎÊÌ⣨±¾ÎĽöÊÇ×÷Ϊ¼òµ¥½éÉÜ£©£º
Ò»¡¢ÃÜÂëѧÉÏ ......