ÓÃJspÊä³öWord,PDFµÈÎļþʱ½øÐеÄÉèÖÃ
response.setContentType( "application/pdf" ); // MIME type for pdf doc
response.setHeader("Content-Disposition","attachment;filename=output.pdf;");
Sets the Content-Type header. Content-Type identifies the MIME type of the response document and the character set encoding.
To set the Content-Type header, use the following code:
response.setContentType("text/html; charset=gbk");
The default MIME type is text/plain. Some common MIME types include:
HTML format (.htm or .html): text/html
Adobe Portable Document (pdf): application/pdf
Microsoft Word (.doc): application/msword
Microsoft Excel (.xls): application/msexcel
Microsoft Powerpoint (.ppt): application/ms-powerpoint
Realaudio (.rm, .ram): audio/x-pn-realaudio
Text format (.txt): text/txt
Zipped files (.zip): application/zip
Ïà¹ØÎĵµ£º
JSP+JavaScrip
t´òÔì¶þ¼¶¼¶ÁªÏÂÀ²Ëµ¥£º
(¸öÈ˲©¿Í£ºwww.duduct.com)
class(Ò»¼¶À¸Ä¿ÐÅÏ¢£©£ºclassId(×Ô¶¯±àºÅ£©£¬className£¨À¸Ä¿Ãû³Æ£©,
Nclass£¨¶þ¼¶À¸Ä¿ÐÅÏ¢£©,
NclassId£¨×Ô¶¯±àºÅ£©£¬NclassName(À¸Ä¿Ãû³Æ£©£¬parentId£¨Ò»¼¶À¸Ä¿id£¬Óëclass±íÖеÄclassId¹ØÁª£©
......
½¨Á¢×ÔÒѵÄwebĿ¼
¿ÉÒÔ½«JSPÒ³Ãæ³ÌÐò²¿ÊðÔÚTomcat·þÎñÆ÷µÄĬÈÏwebĿ¼Ï£¬Ò²¿ÉÒÔ²¿ÊðÔÚ×ÔÒÑ´´½¨µÄwebĿ¼Ï¡£ÏÂÃæÊÇ´´½¨webĿ¼µÄ²½Ö裺
1)£®ÔÚ·þÎñÆ÷ÉÏ´´½¨×ÔÒѵÄĿ¼
È磬´´½¨Ò»Ä¿Â¼£º E:\test\10
2)£®ÅäÖÃwebĿ¼
ÓüÇʱ¾´ò¿ª \Tomcat 5.0\confĿ¼ÏµÄÎļþs ......
Ò».request¶ÔÏó
¿Í»§¶ËµÄÇëÇóÐÅÏ¢±»·â×°ÔÚrequest¶ÔÏóÖУ¬Í¨¹ýËü²ÅÄÜÁ˽⵽¿Í»§µÄÐèÇó£¬È»ºó×ö³öÏìÓ¦¡£ËüÊÇHttpServletRequestÀàµÄʵÀý¡£
µ±request¶ÔÏó»ñÈ¡Óû§Ìá½»µÄºº×Ö×Ö·ûʱ£¬»á²úÉúÂÒÂ룬ÓÉÏÂÃæµÄ·½·¨¿ÉÒÔ½â¾ö£º
¡¡¡¡ Sting s2 = new String(s1.getBytes("iso8859-1"),"GB2312") ......
setAttribute()ÊÇÓÃÓÚ·þÎñÆ÷¶ËÉèÖÃÊôÐÔÏò¿Í»§¶Ë·¢Ë͸ÃÊôÐÔ£¬ÔÚ¿Í»§¶Ëͨ¹ýgetAttribute£¨£©»ñµÃÊôÐÔ¡£setAttribute()Ò²ÄÜ´«µÝ¶ÔÏó¡£
setParameter()Êǿͻ§¶ËÏò·þÎñÆ÷¶Ë·¢ËÍÊôÐÔ£¬Ö»ÄÜ´«×Ö·û£¬ÓÃÓÚget/postµÄÊýÖµ´«µÝ£¬ÔÚ·þÎñ¶ËÓÃgetParameter£¨£©»ñÈ¡£¬Ò³ÃæÖÐÓÐforward´Ó¶¨ÏòÒ³ÃæµÄµØÖ·ÖеIJÎÊýÒ²ÄÜÓÃgetParameter£¨£©»ñÈ¡¡ ......
JSPÄÚ½¨¶ÔÏó- -
¢Ù out - javax.servlet.jsp.jspWriter
out¶Ô ......