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; /
Ïà¹ØÎĵµ£º
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
--from MyEclipse, automatically generate. ......
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.ÔÚ·þÎñÆ÷µÄ¶¯Ì¬ÍøÒ³ÖнûÖ¹»º´æ£¬Òª¼ÓÈëÀàË ......
¹Ø¼ü×Ö: struts2 webwork
½ñÌìÓöµ½Ò»¸öÇé¿ö,ÒªÔÚjspÒ³ÃæÉÏ´¦Àí²éѯ³öÀ´listÒ³µÄһЩÊý¾Ý,¸Ä±äActionÀàÌ«Âé·³,ÓÚÊÇÏëµ½´ÓÒ³ÃæÉÏÖ±½Ó»ñÈ¡ActionÖеıäÁ¿Öµ,²¢½øÐвÙ×÷,ÏÖÔÚ°Ñ»ñÈ¡·½·¨¼Ç¼һÏÂ,ÒÔ±ãÒÔºó²éѯ.
Èç¹ûÔÚActionÀàÀïÓÐÒ»¸ö¼òµ¥µÄ±äÁ¿,²¢ÇÒÒѾдºÃÁËËüµÄgetºÍset·½·¨
private String test="jsp ......
goodsbean.java
package sale;
public class goodsbean{
String Product;
double Price;
public goodsbean (){
this.Product = "box";
this.Price = 5.0;
}
public void setProduct (String ......