ÔÚjspÖÐÈçºÎ×öÏÂÔØ£¿
ÎÒÓÃa±êǩʵÏÖÁËÒ»¸öÏÂÔع¦ÄÜ£¬ÎªÊ²Ã´²»ÄÜÏÂÔØ£¿ÊÇÎҵķ¾¶ÖÐÓÐÖÐÎÄ£¿»¹ÊÇÓþø¶Ô·¾¶µÄÔÒò£¿
Çë´ó¼Ò¸æËßÎÒ£¬ÕâÑù×öÓÐʲôҪעÒâµÄµØ·½Ã»ÓУ¿
aʵÏÖÏÂÔع¦ÄÜ£¿
1. <a href="down.jsp">ÏÂÔØÎļþ </a>
2.down.jsp
<%@ page contentType="application/vnd.ms-word;charset=gb2312" %>
<%@ page import="java.io.*" %>
<%
response.setContentType("application/vnd.ms-word");
out.clearBuffer(); // Èç¹ûʹÓÃJSP,ÐèÒª¼ÓÉÏÕâÒ»¾ä
response.addHeader("Content-Disposition", new String(("filename=ÎÒµÄÎĵµ.doc").getBytes("GBK"), "ISO-8859-1"));
//Õë¶ÔÖÐÎÄÎļþÃû£ºnew String(("attachment;filename=ÎÒµÄÎĵµ.doc").getBytes("GBK"), "ISO-8859-1"));
OutputStream os = response.getOutputStream(); // Ò³ÃæÊä³öÁ÷£¬jsp/servlet¶¼¿ÉÒÔ
os.write("hello£¬ÄãºÃ£¡".getBytes("GB2312"));
os.close();
%>
ÎÒÏÖÔÚÈÏΪÊÇtomcatÅäÖõÄÎÊÌ⣿ÊDz»ÊÇtomcatµÄÔÒò£¿Èç¹ûÒªÏÂÔØ£¬ÊDz»ÊÇÒªÔÚtomcatµÄʲôµØ·½½øÐÐÒ»ÏÂÅäÖã¿
òËƲ»ÓÃÅäÖðÉ!
¾¡Á¿²»ÒªÓÃÖÐÎÄ¡£
response.addHeader.....ÎҼǵÃ
Ïà¹ØÎÊ´ð£º
ÔÚ²éѯºó½«²éѯ³öÀ´µÄÖµ¸³¸ø¸÷ÊäÈë¿ò
<c:if test="${not empty dataValue}">
fm.SAMPLING_DATE.value=" <c:out value='${dataValue.SAMPLING_DATE}'/ ......
ÎÒÔÚjspÒ³Ãæ´æÉÏÒ»¸ösession,±¾Ò³Ã滹¿ÉÒÔÈ¡³öÖµÀ´.
µ«ÊÇһˢÐÂ,»òÕß´ò¿ªÐµÄÒ³Ãæ¾ÍÈ¡²»³öÖµÀ´ÁË.
Ææ¹ÖµÄÊÇ,ÎÒ²âÊÔÁíÒ»¸ö³ÌÐòʱºò
ÔÚjspÒ³Ãæ´æÉÏÒ»¸ösession,±¾Ò³Ãæ¿ÉÒÔÈ¡³öÖµÀ´,ˢлò´ò¿ªÐÂÒ³ÃæÖµÄÜÈ¡³öÀ´ÁË.
......
include.jspÖÐ
<jsp:include page="divide.jsp?value1=2&value2=3 flush="true">
value1 , value2 µÄÖµ¿ÉÒÔ´ÓÉÏÒ»¸ö´«¸øinclude.jspµÄdata.jspÖÐÈ¡Âð£¿
Èç¹û¿ÉÒÔÕâôд° ......
ÓÃͨ¹ýseverletÅäÖõÄÑé֤ͼÏÔʾ²»³öÀ´£¬¶øÓÃJSP×öµÄͼûÎÊÌ⣬¹À¼ÆÊÇWEB.XMLÅäÖÃÓÐÎÊÌ⣬Çó½Ì¸ßÊÖ£¬
ÊDz»ÊÇseverletÇëÇó±»ÆäËûFilterÀ¹½ØÁË£¿
Éú³ÉÑé֤ͼƬµÄJAVAÀà
Java code
package com.ding ......