½â¾öjsp»òserverlet ²»ÄܽâÎömultipart/form
½â¾öjsp»òserverlet ²»ÄܽâÎömultipart/form-data ÀàÐÍµÄ±íµ¥ÓòµÄÎÊÌâ
10 6ÔÂ 2008
Situation:
Javax.servlet.HttpServletRequest.getParameter(String) returns null when the ContentType is multipart/form-data
Solutions:
Solution A:
1. download http://www.servlets.com/cos/index.html
2. invoke getParameters() on com.oreilly.servlet.MultipartRequest
Solution B:
1. download http://jakarta.apache.org/commons/sandbox/fileupload/
2. invoke readHeaders() in
org.apache.commons.fileupload.MultipartStream
Solution C:
1. download http://users.boone.net/wbrameld/multipartformdata/
2. invoke getParameter on
com.bigfoot.bugar.servlet.http.MultipartFormData
Solution D:
Use Struts. Struts 1.1 handles this automatically.
Solution E:
use jspSmartUpload compounds
http://ckasj.vicp.net/dokuwiki/doku.php/freespace:smart_upload
Ïà¹ØÎĵµ£º
JSP¶¯×÷ÀûÓÃXMLÓï·¨¸ñʽµÄ±ê¼ÇÀ´¿ØÖÆServletÒýÇæµÄÐÐΪ¡£ÀûÓÃJSP¶¯×÷¿ÉÒÔ¶¯Ì¬µØ²åÈëÎļþ¡¢ÖØÓÃJavaBean×é¼þ¡¢°ÑÓû§Öض¨Ïòµ½ÁíÍâµÄÒ³Ã桢ΪJava²å¼þÉú³ÉHTML´úÂë¡£
JSP¶¯×÷°üÀ¨£º
jsp:include£ºÔÚÒ³Ãæ±»ÇëÇóµÄʱºòÒýÈëÒ»¸öÎļþ¡£
jsp:useBean£ºÑ°ÕÒ»òÕßʵÀý»¯Ò»¸öJavaBean¡£
jsp:setProperty£ºÉèÖÃJavaBeanµÄÊôÐÔ¡£ ......
ÎÒÃǶ¼ÖªµÀÔÚjspÖÐincludeÓÐÁ½ÖÖÐÎʽ,·Ö±ðÊÇ
<%@ include file=" "%>
<jsp:include page=" " flush="true"/>
Ç°ÕßÊÇÖ¸ÁîÔªËØ¡¢ºóÕßÊÇÐÐΪԪËØ.
ͨ³£µ±Ó¦ÓóÌÐòÖÐËùÓеÄÒ³ÃæµÄijЩ²¿·Ö(ÀýÈç±êÌâ¡¢Ò³½ÅºÍµ¼º½À¸)¶¼ÏàͬµÄʱºò,Î ......
1£¬JSPÖж¯Ì¬INCLUDEÓ뾲̬INCLUDEµÄÇø±ð£¿
¶¯Ì¬INCLUDEÓÃjsp:include¶¯×÷ʵÏÖ <jsp:include page="included.jsp" flush="true" />Ëü×ÜÊÇ»á¼ì²éËùº¬ÎļþÖеı仯£¬ÊʺÏÓÃÓÚ°üº¬¶¯Ì¬Ò³Ã棬²¢ÇÒ¿ÉÒÔ´ø²ÎÊý¡£
####Õâ¸öÊÇ°ÑÒýÓõÄjsp±àÒë³ÉservletÒÔºó£¬Ö±½Óµ÷ÓÃservletÀàµÄ×ö·¨¡£####
¾²Ì¬INCLUDEÓÃinc ......
¢Ù out - javax.servlet.jsp.jspWriter
out¶ÔÏóÓÃÓڰѽá¹ûÊä³öµ½ÍøÒ³ÉÏ¡£
·½·¨£º
1. void clear() ;
Çå³ýÊä³ö»º³åÇøµÄÄÚÈÝ£¬µ«ÊDz»Êä³öµ½¿Í»§¶Ë¡£
2. void clearBuffer() ;
Çå³ýÊä³ö»º³åÇøµÄÄÚÈÝ£¬²¢Êä³öµ½¿Í»§¶Ë¡£
3. void close() ;
¹Ø±ÕÊä³öÁ÷£¬Çå³ýËùÓÐÄÚ ......
1. RequestDispatcher.forward()
ÊÇÔÚ·þÎñÆ÷¶ËÆð×÷ÓÃ,µ±Ê¹ÓÃforward()ʱ,Servlet engine´«µÝHTTPÇëÇó´Óµ±Ç°µÄServlet or JSPµ½ÁíÍâÒ»¸öServlet,JSP »òÆÕͨHTMLÎļþ,Ò²¼´ÄãµÄformÌá½»ÖÁa.jsp,ÔÚa.jspÓõ½ÁËforward()Öض¨ÏòÖÁb.jsp,´ËʱformÌá½»µÄËùÓÐÐÅÏ¢ÔÚ b.jsp¶¼¿ÉÒÔ»ñµÃ,²ÎÊý×Ô¶¯´«µÝ. µ«fo ......