Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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+ajax×Ô¶¯Ë¢ÐÂʵÀý(ת)


Ò»¡¢´¦ÀíajaxÇëÇóµÄjspÎļþ£ºauto.jsp
<%@ page contentType="text/html; charset=gb2312" %>
<%
//ÉèÖÃÊä³öÐÅÏ¢µÄ¸ñʽ¼°×Ö·û¼¯
response.setContentType("text/xml; charset=UTF-8");
response.setHeader("Cache-Control","no-cache&q ......

JSP¡¢Struts±ÜÃâFormÖظ´Ìá½»µÄ¼¸ÖÖ·½°¸

1 javascript £¬ÉèÖÃÒ»¸ö±äÁ¿£¬Ö»ÔÊÐíÌá½»Ò»´Î¡£



2 »¹ÊÇjavascript£¬½«Ìá½»°´Å¥»òÕßimageÖÃΪdisable

onsubmit="getElById('submitInput').disabled = true; return true;">


3 ÀûÓÃstrutsµÄͬ²½ÁîÅÆ»úÖÆ
......

ÎÒµÄJSPѧϰ±Ê¼Ç JSPÒ³ÃæÖеÄÈýÀà»ù±¾ÔªËØ

JSPÒ³ÃæµÄÈýÀà»ù±¾ÔªËØ
 
1.ÉùÃ÷
 
ÐÎÈç
<%!
      int a;
      int add(int a,int b)
      {
           return a+b;
       ......

jsp½ûÖ¹Ò³Ã滺´æ

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.ÔÚ·þÎñÆ÷µÄ¶¯Ì¬ÍøÒ³ÖнûÖ¹»º´æ£¬Òª¼ÓÈëÀàË ......

»ùÓÚJSPµÄÎïÁ÷¹ÜÀíƽ̨

Ñ¡ÌâÒÀ¾Ý¼°Ñо¿ÒâÒå
ÏÖ´úÎïÁ÷£¬ÊÇÖ¸²úÆ·´ÓÉú²úµØµ½Ïû·ÑµØÖ®¼äµÄÕû¸ö¹©Ó¦Á´£¬ÔËÓÃÏȽøµÄ×éÖ¯·½Ê½ºÍ¹ÜÀí¼¼Êõ£¬½øÐиßЧÂʼƻ®¡¢¹ÜÀí¡¢ÅäËÍÁ´£¬ÎªÓû§Ìṩ¶à¹¦ÄÜ¡¢Ò»Ì廯µÄ×ÛºÏÐÔ·þÎñ£¬´Ó¶ø´ïµ½½µµÍÁ÷ͨ³É±¾¡¢Ìá¸ßÉú²úЧÂÊ¡¢Ôö¼ÓÆóÒµÀûÈó¡£µÄÐÂÐÍ·þÎñÒµ¡£Ëüͨ¹ý¶ÔÔËÊä¡¢²Ö´¢¡¢×°Ð¶¡¢¼Ó¹¤¡¢ÕûÀí¡¢ÅäËÍÓëÐÅÏ¢µÈ·½ÃæÓлú½áºÏ£¬ÐÎ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ