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; /
Ïà¹ØÎĵµ£º
×î½ü×öÁËÒ»¸ö×ʷѲéѯģ¿é£¬ÀïÃæÉæ¼°½«×Ê·ÑÐÅÏ¢µ¼³öWordÎĵµºÍExcelÎĵµ£¬
ÏÈ˵˵µ¼³öWordÎĵµ£º
Æäʵ¾ÍÊÇ°ÑÏìÓ¦µÄÀàÐÍÉèΪapplication/msword,È»ºó°ÑÄÚÈÝÊä³öµ½Õâ¸öÎļþ¾ÍÐÐÁË
µÚÒ»²½£º
ÏÈÔÚ×ÀÃæÉÏн¨Ò»¸öwordÎĵµ,Ë«»÷´ò¿ª£¬È»ºóÁí´æΪ.htmÎļþ£¬»á²úÉúÒ»¸öÒÔ.htm½áβµÄÎļþ
µÚ¶þ²½£º
°Ñ.htmÎļþÀ©Õ¹Ãû¸ÄΪ.jspÎļ ......
Ò»°ã£¬ÔںܶàÓ¦ÓÃϵͳÖУ¬Óû§¶à´ÎÌá½»Öظ´Êý¾ÝÊÇÒ»¸öºÜÑÏÖصÄÎÊÌ⣬»áµ¼ÖÂÓ¦ÓÃϵͳÖкܶàÀ¬»øÊý¾Ý£¬ÔÚStrutsÖпò¼ÜÖУ¬ÓÐTOKEN»úÖÆÀ´·ÀÖ¹Óû§Ìá½»Öظ´Êý¾Ý£¬ÕâÊÇÒ»¸öºÜºÃµÄ°ì·¨£¬µ«ÊÇ£¬TOKEN»úÖƱØÐëµÃÓõ½html:form±êÇ©£¬ÎÒ²»Ï²»¶ÓÃÕâ¸ö±êÇ©£¬ÎÒ¾õµÃÊÇÒ»¸öÀÛ׸£¬ËùÒÔÎÒÈ¥µôHTML:FORM±êÇ©£¬ÖØж¨ÒåTOK ......
JSPÒ³ÃæÖÐÒ»°ãÓÐÁ½Àà×¢ÊÍ
1.html×¢ÊÍ
ÐÎÈç<!--...................-->
Ëü»áͬhtml±ê¼Çһͬ·¢µ½¿Í»§¶Ë
2.jsp×¢ÊÍ£¨3ÖÖ£©
ÐÎÈç<%--.............................--%>
Ëü²»»á±»·¢Ë͵½¿Í»§¶Ë£¬Ö»ÓÃÀ´×¢ÊÍ·þÎñÆ÷¶ËµÄjspÎļþ£¬Á¬jspÉú³ÉµÄservletҲûÓÐ×¢ÊͽøÈ¥£¬ÕâÒ²ÊǴ󲿷ÖÈËʹÓõÄ×¢ÊÍ
ÐÎÈç<%//...... ......
1.½ûÖ¹¿Í»§¶Ë»º´æÒªÔÚ<head>ÖмÓÈëÀàËÆÈçÏÂÄÚÈÝ£º
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
2.ÔÚ·þÎñÆ÷µÄ¶¯Ì¬ÍøÒ³ÖнûÖ¹»º´æ£¬Òª¼ÓÈëÀàË ......
goodsbean.java
package sale;
public class goodsbean{
String Product;
double Price;
public goodsbean (){
this.Product = "box";
this.Price = 5.0;
}
public void setProduct (String ......