JSP²ÊÉ«ÑéÖ¤Âë
JSP²ÊÉ«ÑéÖ¤Âë
Éú³ÉÓÐ4¸öËæ»úÊý×ÖºÍÔÓÂÒ±³¾°µÄͼƬ£¬Êý×ֺͱ³¾°ÑÕÉ«»á¸Ä±ä£¬·þÎñÆ÷¶ËˢУ¨ÓÃhistory.go(-1)Ò²»á±ä£©
ÔÐͲο¼ALIBABA http://china.alibaba.com/member/showimage
²úÉúÑéÖ¤ÂëͼƬµÄÎļþ-----image.jsp
<%@ page contentType="image/jpeg" import="java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*" %>
<%!
Color getRandColor(int fc,int bc){//¸ø¶¨·¶Î§»ñµÃËæ»úÑÕÉ«
Random random = new Random();
if(fc>255) fc=255;
if(bc>255) bc=255;
int r=fc+random.nextInt(bc-fc);
int g=fc+random.nextInt(bc-fc);
int b=fc+random.nextInt(bc-fc);
return new Color(r,g,b);
}
%>
<%
//ÉèÖÃÒ³Ãæ²»»º´æ
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
// ÔÚÄÚ´æÖд´½¨Í¼Ïó
int width=60, height=20;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// »ñȡͼÐÎÉÏÏÂÎÄ
Graphics g = image.getGraphics();
//Éú³ÉËæ»úÀà
Random random = new Random();
// É趨±³¾°É«
g.setColor(getRandColor(200,250));
g.fillRect(0, 0, width, height);
//É趨×ÖÌå
g.setFont(new Font("Times New Roman",Font.PLAIN,18));
//»±ß¿ò
//g.setColor(new Color());
//g.drawRect(0,0,width-1,height-1);
// Ëæ»ú²úÉú155Ìõ¸ÉÈÅÏߣ¬Ê¹Í¼ÏóÖеÄÈÏÖ¤Âë²»Ò×±»ÆäËü³ÌÐò̽²âµ½
g.setColor(getRandColor(160,200));
for (int i=0;i<155;i++)
{
int x = random.nextInt(width);
int y = random.nextInt(height);
int xl = random.nextInt(12);
int yl = random.nextInt(12);
g.drawLine(x,y,x+xl,y+yl);
}
// È¡Ëæ»ú²úÉúµÄÈÏÖ¤Âë(4λÊý×Ö)
String sRand="";
for (int i=0;i<4;i++){
String rand=String.valueOf(random.nextInt(10));
sRand+=rand;
// ½«ÈÏÖ¤ÂëÏÔʾµ½Í¼ÏóÖÐ
g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); //µ÷Óú¯Êý³öÀ´µÄÑÕÉ«Ïàͬ£¬¿ÉÄÜÊÇÒòΪÖÖ×ÓÌ«½Ó½ü£¬ËùÒÔÖ»ÄÜÖ±½ÓÉú³É
g.drawString(rand,13*i+6,16);
}
// ½«ÈÏÖ¤Âë´æÈëSESSION
session.setAttribute("rand",sRand);
// ͼÏóÉúЧ
g.dispose();
// Êä³öͼÏóµ½Ò³Ãæ
ImageIO
Ïà¹ØÎĵµ£º
´ÓÍøÉϲéÕÒ×ÊÁÏjava/jsp»ñµÃ¿Í»§¶Ë(IE)Íø¿¨MACµØÖ·µÄ·½·¨´ó¸ÅÓÐÈýÖÖ¡£
1¡¢Í¨¹ýÃüÁʽ£¬ÔÚ¿Í»§¶ËÖ´ÐÐIpconfig µÈµÈ
2¡¢Í¨¹ýActiveXµÄ·½·¨
3¡¢Í¨¹ýÏò137µÄ¶Ë¿Ú·¢ËͲéѯָÁîµÄ·½·¨
¼ò½é£º
µÚÒ»ÖÖ·½·¨,ÔÚÕæÕýÓõ½Ê±ºò²»ÖªµÀΪʲô»ñµÃmacµØÖ·µÄÖ¸Áî×èÈûÁË,²»ÍùϼÌÐøÖ´ÐС£¶øÇÒËÙ¶ÈÊÇÕâÈýÖÖ·½·¨ÖÐ×îÂýµÄÒ»ÖÖ¡£
´úÂëÈçÏ ......
1¡¢jspÒ³ÃæÂÒÂ룺
ÔÚjspÒ³Ã濪ʼÌí¼Ó<%pageEncoding="uft-8"%>
2¡¢servletÊä³öÂÒÂ룺
ÔÚÊä³öÄÚÈÝ֮ǰ£¬ÏÈÖ´ÐÐresponse.setContentType
("text/html;charset=utf-8")
3¡¢ÔÚformÀïÓÃpost·½Ê½Ìá½»²ÎÊý£º
1£©½ÓÊÕʱ¼Órequest.setCharacterEncoding("utf-8")
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 ......
¸Õ¿ªÊ¼Ñ§jsp£¬×öµÄÒ»µãÌý¿Î±Ê¼Ç¡£
1.jspÈý´óÖ¸Áî
<%@ page ~~~~~~~~ %>
<%@ include file=""%>
<%@ taglib url="" prfix=""%>
2.if(username.equals(""))
out.println("ÐÕÃû²»ÄÜΪ¿Õ£¬Çë<a href=javascript:history.back()>·µ»Ø")£»
&&·ÀÖ¹Ö±½ÓÔÚä¯À ......
JSPµ÷ÓÃJavaBeanÔÚÍøÒ³É϶¯Ì¬Éú³ÉÖù״ͼ
ÎÒÃǾ³£ÒªÔÚÍøÒ³¿´µ½Ò»Ð©¶¯Ì¬¸üеÄͼƬ,×î³£¼ûµÄĪ¹ýÓÚ¹ÉƱµÄKÏßͼ£¬±¾ÎÄÊÔͼͨ¹ýÒ»¸ö¼òµ¥µÄʵÀý£¬Ïò´ó¼ÒչʾÈçºÎͨ¹ýJSP µ÷ÓÃJavaBeanÔÚÍøÒ³É϶¯Ì¬Éú³ÉÖù״ͼ¡£
¡¡¡¡±³¾°£º±¾ÈË×î½üÔÚΪijͳ¼Æ¾Ö¿ª·¢ÏîĿʱ,Éæ¼°µ½ÔÚÍøÒ³É϶¯Ì¬Éú³ÉͼƬµÄÎÊÌ⣬·ÑÁËÒ»ÌìµÄʱ¼ä,ÖÕÓڸ㶨,Ϊ°ïÖú´ó ......