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

JSPÎļþÏÂÔØ¡¢ÉÏ´«

JSPÎļþÏÂÔØ-----------------------------------------------------------------
<%@ page contentType="text/html; charset=GBK"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="java.io.File"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.io.FileInputStream"%>
<%
String path = request.getParameter("path") ;
if(path==null || "".equals(path)){
out.write("<mce:script type="text/javascript"><!--
") ;
out.write("alert('ÒªÏÂÔصÄÎļþ²»´æÔÚ');") ;
out.write("history.go(-1);") ;
out.write("
// --></mce:script>") ;
}
String realPath = "c:/myfile/ÕýÎÄ.doc" ;
File file = new File(realPath) ;
if(!file.exists()){
out.write("<mce:script type="text/javascript"><!--
") ;
out.write("alert('ÒªÏÂÔصÄÎļþ²»´æÔÚ');") ;
out.write("history.go(-1);") ;
out.write("
// --></mce:script>") ;
}else{
long l = file.length() ;
InputStream in = new FileInputStream(file) ;
String fs = file.getName() ;
if(in!=null){
response.reset();
response.setContentType("application/x-msdownload");
response.setHeader("Content-disposition","attachment; filename="+new String(fs.getBytes("GBK"),"iso8859-1"));
//ÒÔÉÏÊä³öÎļþÔªÐÅÏ¢
response.setContentLength((int)l); //ÉèÖÃÊäÈëÎļþ³¤¶È
byte[] b = new byte[2048];
int len = 0;
while((len=in.read(b)) >0)
response.getOutputStream().write(b,0,len); //Ïòä¯ÀÀÆ÷Êä³ö
in.close(); //¹Ø±ÕÎļþÊäÈëÁ÷
response.flushBuffer();
out.clear();
out = pageContext.pushBody();
}
}
%>
ÎļþÉÏ´«----------------------------------------------------------------------
Ìá½»Ò³Ãæ-------------
<form method="POST" enctype="multipa


Ïà¹ØÎĵµ£º

JSP±àÂ볣ʶ[ת]

GBK±àÂë
GBK±àÂëÊÇÖйúÖƶ©µÄ¡¢µÈͬÓÚUCSµÄеÄÖÐÎıàÂëÀ©Õ¹¹ú¼Ò±ê×¼¡£GBK¹¤×÷С×éÓÚ1995Äê10Ô£¬Í¬Äê12ÔÂÍê³ÉGBK¹æ·¶¡£¸Ã±àÂë±ê×¼¼æÈÝGB2312£¬¹²ÊÕ¼ºº×Ö21003¸ö¡¢·ûºÅ883¸ö£¬²¢Ìṩ1894¸öÔì×ÖÂë룬¼ò¡¢·±Ìå×ÖÈÚÓÚÒ»¿â¡£
UTF-8±àÂë
UTF-8±àÂë¿ÉÒÔͨ¹ýÆÁ±ÎλºÍÒÆλ²Ù×÷¿ìËÙ¶Áд¡£×Ö·û´®±È½Ïʱstrcmp()ºÍwcscmp()µÄ·µ»Ø½ ......

Jsp ÒýÓà css ÑùʽÎļþÎÞЧµÄÎÊÌâ½â¾ö

ÐÞ¸ÄÁËcss ÑùʽÎļþºó£¬ÖØÐÂä¯ÀÀ¸ÃjspÒ³Ã棬·¢ÏÖÐÂÐ޸ĵÄÑùʽûÓÐÉúЧ¡£×ÜÒÔΪÊÇÏîÄ¿»º´æËùÒýÆðµÄ£¬ÓÚÊÇÇåÀíËùÓÐÏîÄ¿£¬ÖØй¹½¨ÏîÄ¿¡£²»ÐС£Ö´ÐÐserver µÄ publish »¹ÊDz»ÐС£ÓÃwindow µÄËÑË÷¹¦ÄÜ·¢ÏÖ³ýÁË WebContent Ŀ¼Óиà css ÎļþÍ⣬.metadata\.plugins\org.eclipse.wst.server.core\tmp1\webapps\ Ŀ¼ÏÂÒ²´æÔڸà c ......

mysql ÖÐÐÂÎÅÀà×Ô¶¯»»ÐÐÏÔʾÔÚjspÒ³Ãæ

Ö»Ðè´ÓÊý¾Ý¿â²é³öÀ´ºóÔÚÏÔʾµÄµØ·½ÓÃ<pre></pre>±êÇ©ÐÞÊΣ¬ÈçÏ£º
<!--
     <div style="font-size:12px;color:green;text-align:left">
     <pre>
      <%=
        &n ......

ÒýÓà JSP:contentType ÓëpageEncodingÇø±ð

pageEncoding
ÔÚJSP±ê×¼µÄÓï·¨ÖУ¬Èç¹ûpageEncodingÊôÐÔ´æÔÚ£¬ÄÇôJSPÒ³ÃæµÄ×Ö·û±àÂ뷽ʽ¾ÍÓÉpageEncoding¾ö¶¨£¬·ñÔò¾ÍÓÉcontentTypeÊôÐÔÖеÄcharset¾ö¶¨£¬Èç¹ûcharsetÒ²²»´æÔÚ£¬JSPÒ³ÃæµÄ×Ö·û±àÂ뷽ʽ¾Í²ÉÓÃĬÈϵÄISO-8859-1¡£
ContentType
ContentTypeÊôÐÔÖ¸¶¨ÁËMIMEÀàÐͺÍJSPÒ³Ãæ»ØӦʱµÄ×Ö·û±àÂ뷽ʽ¡£MIMEÀàÐ굀 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ