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

jspÉÏ´«Í·ÏñÒÔ¼°Éú³ÉËõÂÔͼ


<%@ page autoFlush="false" contentType="text/html;charset=utf-8" language="java" import="java.io.*,java.awt.Image,java.awt.image.*,com.sun.image.codec.jpeg.*,java.sql.*,com.jspsmart.upload.*,java.util.*,java.io.FileInputStream,java.io.FileOutputStream,java.awt.*"%>
<%@ page import="com.blog.vo.*" %>
<%
SmartUpload mySmartUpload =new SmartUpload();
long file_size_max=4000000;
String fileName2="",ext="",testvar="";
String url="uploadfile/images/"; //Ó¦±£Ö¤ÔÚ¸ùĿ¼ÖÐÓдËĿ¼µÄ´æÔÚ
//³õʼ»¯
mySmartUpload.initialize(pageContext);
//Ö»ÔÊÐíÉÏÔØ´ËÀàÎļþ
try {
mySmartUpload.setAllowedFilesList("jpg,gif,JPG,GIF");
//ÉÏÔØÎļþ
mySmartUpload.upload();
} catch (Exception e){
%>
<SCRIPT language=javascript>
alert("Ö»ÔÊÐíÉÏ´«.jpgºÍ.gifÀàÐÍͼƬÎļþ");
window.location='face.jsp';
</script>
<%
}
try{
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
if (myFile.isMissing()){%>
<SCRIPT language=javascript>
alert("ÇëÏÈÑ¡ÔñÒªÉÏ´«µÄÎļþ");
window.location='face.jsp';
</script>
<%}
else{
//String myFileName=myFile.getFileName(); //È¡µÃÉÏÔصÄÎļþµÄÎļþÃû
ext= myFile.getFileExt(); //È¡µÃºó׺Ãû
int file_size=myFile.getSize(); //È¡µÃÎļþµÄ´óС
String saveurl="";
if(file_size<file_size_max){
//¸ü¸ÄÎļþÃû£¬È¡µÃµ±Ç°ÉÏ´«Ê±¼äµÄºÁÃëÊýÖµ
Calendar calendar = Calendar.getInstance();
String filename = String.valueOf(calendar.getTimeInMillis());
saveurl=request.getRealPath("/")+url;
saveurl+=filename+"."+ext; //±£´æ·¾¶
myFile.saveAs(saveurl,mySmartUpload.SAVE_PHYSICAL);
//-----------------------ÉÏ´«Íê³É£¬¿ªÊ¼Éú³ÉËõÂÔͼ-------------------------
java.io.File file = new java.io.File(saveurl); //¶ÁÈë¸Õ²ÅÉÏ´«µÄÎļþ
String newurl=request.getRealPath("/")+url+filename+"_min."+ext; //еÄËõÂÔͼ±£´æµØÖ·
Image src = javax.imageio.ImageIO.read(file); //¹¹ÔìImage¶ÔÏó
float tagsize=110;
int old_w=src.getWidth(null); //µÃµ½Ô´Í¼¿í
int old_h=src.getHeight(null);
int new_w=0;
int new_h=0; /


Ïà¹ØÎĵµ£º

jspµ¼³öword ¼°mht תÂëÎÊÌâ

×î½ü×öÁËÒ»¸ö×ʷѲéѯģ¿é£¬ÀïÃæÉæ¼°½«×Ê·ÑÐÅÏ¢µ¼³öWordÎĵµºÍExcelÎĵµ£¬
ÏÈ˵˵µ¼³öWordÎĵµ£º
Æäʵ¾ÍÊÇ°ÑÏìÓ¦µÄÀàÐÍÉèΪapplication/msword,È»ºó°ÑÄÚÈÝÊä³öµ½Õâ¸öÎļþ¾ÍÐÐÁË
µÚÒ»²½£º
ÏÈÔÚ×ÀÃæÉÏн¨Ò»¸öwordÎĵµ,Ë«»÷´ò¿ª£¬È»ºóÁí´æΪ.htmÎļþ£¬»á²úÉúÒ»¸öÒÔ.htm½áβµÄÎļþ
µÚ¶þ²½£º
°Ñ.htmÎļþÀ©Õ¹Ãû¸ÄΪ.jspÎļ ......

ÎÒµÄJSPѧϰ±Ê¼Ç JSPÒ³ÃæÖеÄ×¢ÊÍ

JSPÒ³ÃæÖÐÒ»°ãÓÐÁ½Àà×¢ÊÍ
1.html×¢ÊÍ
ÐÎÈç<!--...................-->
Ëü»áͬhtml±ê¼Çһͬ·¢µ½¿Í»§¶Ë
2.jsp×¢ÊÍ£¨3ÖÖ£©
ÐÎÈç<%--.............................--%>
Ëü²»»á±»·¢Ë͵½¿Í»§¶Ë£¬Ö»ÓÃÀ´×¢ÊÍ·þÎñÆ÷¶ËµÄjspÎļþ£¬Á¬jspÉú³ÉµÄservletҲûÓÐ×¢ÊͽøÈ¥£¬ÕâÒ²ÊǴ󲿷ÖÈËʹÓõÄ×¢ÊÍ
ÐÎÈç<%//...... ......

JSPÖж¯Ì¬INCLUDEÓ뾲̬INCLUDEµÄÇø±ð

ÎÒÃǶ¼ÖªµÀÔÚjspÖÐincludeÓÐÁ½ÖÖÐÎʽ,·Ö±ðÊÇ
    <%@ include file=" "%>
    <jsp:include page=" " flush="true"/>
    Ç°ÕßÊÇÖ¸ÁîÔªËØ¡¢ºóÕßÊÇÐÐΪԪËØ.
    ͨ³£µ±Ó¦ÓóÌÐòÖÐËùÓеÄÒ³ÃæµÄijЩ²¿·Ö(ÀýÈç±êÌâ¡¢Ò³½ÅºÍµ¼º½À¸)¶¼ÏàͬµÄʱºò,Î ......

jspÖÐincludeµÄÁ½ÖÖÐÎʽ

jspÖÐincludeµÄÁ½ÖÖÐÎʽ:      1.<%@ include file=” ”%>
                                 &nbs ......

jspÖÐÎÄÂÒÂë½â¾ö·½°¸


1¡¢jspÒ³ÃæÂÒÂ룺
ÔÚjspÒ³Ã濪ʼÌí¼Ó<%pageEncoding="uft-8"%>
2¡¢servletÊä³öÂÒÂ룺
ÔÚÊä³öÄÚÈÝ֮ǰ£¬ÏÈÖ´ÐÐresponse.setContentType
("text/html;charset=utf-8")
3¡¢ÔÚformÀïÓÃpost·½Ê½Ìá½»²ÎÊý£º
1£©½ÓÊÕʱ¼Órequest.setCharacterEncoding("utf-8")
2£©Ê¹ÓùýÂËÆ÷£¬ÔÚ½ÓÊÕ²ÎÊý֮ǰ£¬É趨´«µÝµÄ²ÎÊýÄ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ