½â¾ö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Ò³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Óʱ³öÏÖÂÒÂë
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔÊ¾Ò³Ãæ(display.jsp)¾ ......
1£¬JSPÖж¯Ì¬INCLUDEÓ뾲̬INCLUDEµÄÇø±ð£¿
¶¯Ì¬INCLUDEÓÃjsp:include¶¯×÷ʵÏÖ <jsp:include page="included.jsp" flush="true" />Ëü×ÜÊÇ»á¼ì²éËùº¬ÎļþÖеı仯£¬ÊʺÏÓÃÓÚ°üº¬¶¯Ì¬Ò³Ã棬²¢ÇÒ¿ÉÒÔ´ø²ÎÊý¡£
####Õâ¸öÊǰÑÒýÓõÄjsp±àÒë³ÉservletÒÔºó£¬Ö±½Óµ÷ÓÃservletÀàµÄ×ö·¨¡£####
¾²Ì¬INCLUDEÓÃinc ......
1 £©Ê×ÏȽ¨Á¢¹ÜÀíÓû§±í£¬ÆäÖÐ UserPopedom ¼Ç¼Óû§µÄȨÏÞ×Ö·û£¬ÆäʵҲ¾ÍÊÇһЩ JSP »òÕß ACTION µÄÎļþÃû£º
CREATE TABLE [dbo].[AdminUser] (
[UserID] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[UserName] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[UserPass] [varchar ......
×¢ÊÍ
ÔÚ¿Í»§¶ËÏÔʾһ¸ö×¢ÊÍ.
JSP Óï·¨
<!-- comment [ <%= expression %> ] -->
Àý×Ó 1
<!-- This file displays the user login screen -->
ÔÚ¿Í»§¶ËµÄHTMLÔ´´úÂëÖвúÉúºÍÉÏÃæÒ»ÑùµÄÊý¾Ý£º
<!-- This file displays the user login screen -->
Àý×Ó 2
<!-- This page was lo ......
Ò» ¡£×Ô¶¨ÒåJSP±êÇ©µÄ´¦Àí¹ý³Ì£º
¡¡ 1£®ÔÚJSPÖÐÒýÈë±êÇ©¿â£º
¡¡ 2£®ÔÚJSPÖÐʹÓñêÇ©¿â±êÇ©
¡¡ 3£®WebÈÝÆ÷¸ù¾ÝµÚ¶þ¸ö²½ÖèÖеÄprefix£¬»ñµÃµÚÒ»¸ö²½ÖèÖÐÉùÃ÷µÄtaglibµÄuriÊôÐÔÖµ
¡¡ 4£®WebÈÝÆ÷¸ù¾ÝuriÊôÐÔÔÚweb.xmlÕÒµ½¶ÔÓ¦µÄÔªËØ
5£®´ÓÔªËØÖлñµÃ¶ÔÓ¦µÄÔªËØµÄÖµ
6£®WebÈÝ ......