Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÓÃ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Ò³Ãæ´«ÖµµÄÂÒÂëÎÊÌâµÄ½â¾ö

jspÒ³ÃæÖ®¼äµÄ´«ÖµÂÒÂëÎÊÌ⣬×ܽáÈçÏ£º
a.jspÍùb.jsp´«Öµ£º
a.jspÒ³ÃæÄÚÈÝ£º
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<form action="b.jsp">
      name:<input type=text name=name>
      <input type=s ......

ÎåÖÖJSPÒ³ÃæÌø×ª·½·¨Ïê½â(1)

1. RequestDispatcher.forward()
ÊÇÔÚ·þÎñÆ÷¶ËÆð×÷ÓÃ,µ±Ê¹ÓÃforward()ʱ,Servlet engine´«µÝHTTPÇëÇó´Óµ±Ç°µÄServlet or JSPµ½ÁíÍâÒ»¸öServlet,JSP »òÆÕͨHTMLÎļþ,Ò²¼´ÄãµÄformÌá½»ÖÁa.jsp,ÔÚa.jspÓõ½ÁËforward()ÖØ¶¨ÏòÖÁb.jsp,´ËʱformÌá½»µÄËùÓÐÐÅÏ¢ÔÚ b.jsp¶¼¿ÉÒÔ»ñµÃ,²ÎÊý×Ô¶¯´«µÝ. µ«forward()ÎÞ·¨Öض¨ÏòÖÁÓÐframeµ ......

jsp servlet ÖÐsetAttribute()ºÍgetParameter()Çø±ð

setAttribute()ÊÇÓÃÓÚ·þÎñÆ÷¶ËÉèÖÃÊôÐÔÏò¿Í»§¶Ë·¢Ë͸ÃÊôÐÔ£¬ÔÚ¿Í»§¶Ëͨ¹ýgetAttribute£¨£©»ñµÃÊôÐÔ¡£setAttribute()Ò²ÄÜ´«µÝ¶ÔÏó¡£
setParameter()Êǿͻ§¶ËÏò·þÎñÆ÷¶Ë·¢ËÍÊôÐÔ£¬Ö»ÄÜ´«×Ö·û£¬ÓÃÓÚget/postµÄÊýÖµ´«µÝ£¬ÔÚ·þÎñ¶ËÓÃgetParameter£¨£©»ñÈ¡£¬Ò³ÃæÖÐÓÐforward´Ó¶¨ÏòÒ³ÃæµÄµØÖ·ÖеIJÎÊýÒ²ÄÜÓÃgetParameter£¨£©»ñÈ¡¡ ......

JSPÖÐʹÓÃIncludeÓëJSP£ºIncludeµÄÇø±ð

ÎÒÃǶ¼ÖªµÀÔÚjspÖÐincludeÓÐÁ½ÖÖÐÎʽ,·Ö±ðÊÇ
< %@ include file=” ”% >
< jsp:include page=” ” flush=”true”/ >
ǰÕßÊÇÖ¸ÁîÔªËØ¡¢ºóÕßÊÇÐÐÎªÔªËØ¡£
¾ßÌåËüÃǽ«Ôںδ¦Óã¿ÈçºÎÓü°ËüÃÇÓÐÊ²Ã´Çø±ð£¿ÕâÓ¦¸ÃÊǺܶàÈË¿´µ½Ëü¶¼»áÏëµ½µÄÎÊÌâ¡£ÏÂÃæÒ»ÆðÀ´¿´¿´°É¡£
ͨ³£ ......

Servlets/JSP¿ª·¢¼¼ÊõÎÊ´ð


ΪʲôGenericServletÔÚinit(ServletConfig config)»ù´¡ÉÏÔö¼ÓÁËÒ»¸öinit()·½·¨£¿
init()·½·¨±»GenericServlet.init(ServletConfig config)·½·¨µ÷Óá£
init()·½·¨·½±ãÁË¿ª·¢ÈËÔ±¶¨ÖÆServletµÄ³õʼ»¯£¬¶øÎÞÐëȥά»¤ServletConfig¶ÔÏóµÄ´æ´¢¹¤×÷¡£
ÖØÐ´GenericServlet.init(ServletConfig config)±ØÐëÒªÏÔʾµÄµ÷ÓÃsuper ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ