Flex+javaʵÏÖÎļþÉÏ´«
ÓÃÁËÁ½Ììʱ¼äѧϰÁËÏÂFlexºÍjavaÅäºÏʵÏÖÎļþÉÏ´«£¬ÕÒÁ˸öСÀý×Ó¡£Ç°¶Ëµ±È»ÊÇflex£¬ºǫ́ʹÓÃservlet£¬°Ñ´úÂëÌùÉÏÀ´£¬±¸Íü°É£º
FileUpload.java:
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
@SuppressWarnings("serial")
public class FileUpload extends HttpServlet
{
//¶¨ÒåÎļþÉÏ´«µÄ·¾¶
private String uploadPath = "d:\\a\\";
private int maxPostSize = 100*1024*1024;
public FileUpload()
{
super();
}
public void destroy()
{
super.destroy();
}
@SuppressWarnings("unchecked")
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException
{
System.out.println("Access!");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print("ÒÑÁ¬½ÓÉÏ!");
//±£´æÎļþµ½·þÎñÆ÷ÖÐ
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setSizeThreshold(4096);
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(maxPostSize);
try
{
List fileItems = upload.parseRequest(request);
Iterator iter = fileItems.iterator();
while(iter.hasNext())
{
FileItem item = (FileItem)iter.next();
if(!item.isFormField())
{
String name = item.getName();
System.out.println(name);
try
{
item.write(new File(uploadPath+name));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
catch(FileUploadException e)
{
e.prin
Ïà¹ØÎĵµ£º
ÉÏÃæÊÇÒ»¸öflex×öµÄÑ¡Ôñ£¬Ö÷ҪѧϰÊý¾Ý Model¸úDateGridµÄÓ÷¨ ¹þ£¬Ô´ÂëÈçÏ£º
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" fontSize="12">
<mx:Model id="books">
<datas>
<book>
  ......
×Ô¶¯×°ÏäÓë²ðÏäµÄ¹¦ÄÜÊÂʵÉÏÊDZàÒëÆ÷À´°ïÄúµÄ棬±àÒëÆ÷ÔÚ±àÒëʱÆÚÒÀÄúËù±àдµÄÓï·¨£¬¾ö¶¨ÊÇ·ñ½øÐÐ×°Ïä»ò²ðÏ䶯×÷¡£ÀýÈ磺
Integer i = 100.Ï൱ÓÚ±àÒëÆ÷×Ô¶¯ÎªÄú×÷ÒÔϵÄÓï·¨±àÒ룺
Integer i = new Integer(100).ËùÒÔ×Ô¶¯×°ÏäÓë²ðÏäµÄ¹¦ÄÜÊÇËùνµÄ“±àÒëÆ÷ÃÛÌÇ”(Compiler Sugar)£¬ËäȻʹÓÃÕâ¸ö¹¦Äܷܺ½±ã£¬µ ......
1.Duplicated Code ´úÂëÖظ´¼¸ºõÊÇ×î³£¼ûµÄÒìζÁË¡£ËûÒ²ÊÇRefactoringµÄÖ÷ҪĿ±êÖ®Ò»¡£´úÂëÖظ´ÍùÍùÀ´×ÔÓÚcopy-and-pasteµÄ±à³Ì·ç¸ñ¡£ÓëËûÏà¶ÔÓ¦OAOOÊÇÒ»¸öºÃϵͳµÄÖØÒª±êÖ¾¡£ 2.Long method ËüÊÇ´«Í³½á¹¹»¯µÄ“ÒŶ¾”¡£Ò»¸ö·½·¨Ó¦µ±¾ßÓÐ×ÔÎÒ¶ÀÁ¢µÄÒâͼ£¬²»Òª°Ñ¼¸¸öÒâͼ·ÅÔÚÒ»Æð¡£ 3.Large Class ´óÀà¾ÍÊÇÄã°ÑÌ«¶ ......
Ctrl+1 ¿ìËÙÐÞ¸´(×î¾µäµÄ¿ì½Ý¼ü,¾Í²»Óöà˵ÁË)
Ctrl+D: ɾ³ýµ±Ç°ÐÐ
Ctrl+Alt+↓ ¸´ÖƵ±Ç°Ðе½ÏÂÒ»ÐÐ(¸´ÖÆÔö¼Ó)
Ctrl+Alt+↑ ¸´ÖƵ±Ç°Ðе½ÉÏÒ»ÐÐ(¸´ÖÆÔö¼Ó)
Alt+↓ µ±Ç°ÐкÍÏÂÃæÒ»Ðн»»¥Î»ÖÃ(ÌرðʵÓÃ,¿ÉÒÔÊ¡È¥ÏȼôÇÐ,ÔÙÕ³ÌùÁË)
Alt+↑ µ±Ç°ÐкÍÉÏÃæÒ»Ðн»»¥Î»ÖÃ(ͬÉÏ)
Alt+← Ç°Ò»¸ö±à¼µ ......
¶ÔÓÚ Java 1.2£¬ÄúÖ»ÐèÓÃ
Authenticator.setDefault() °²×°Ò»¸ö Authenticator¡£ÕâÑù£¬µ±ÐèÒªÈÏ֤ʱ£¬ÒÑ°²×°µÄ Authenticator µÄ
getPasswordAuthentication() ·½·¨¾Í»á±»µ÷Óã¬È»ºóÄú¾Í¿ÉÒÔÓÃÊʵ±µÄÓû§ÃûºÍ¿ÚÁîÀ´ÉèÖà PasswordAuthentication ʵÀý¡£¾ÍÕâô¼òµ¥¡£
package
cn.arthurs.web;
import ja ......