java实现验证码
java验证码的实现(一)
收藏
1.ImageServlet类的实现:
package com.mobile.control;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ImageServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
// 生成数字和字母的验证码
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
BufferedImage img = new BufferedImage(68, 22,
BufferedImage.TYPE_INT_RGB);
// 得到该图片的绘图对象
Graphics g = img.getGraphics();
Random r = new Random();
&
相关文档:
使用Runtime.getRuntime().exec()方法可以在java程序里运行外部程序.
该方法有6个可访问版本:
1.exec(String command)
2.exec(String command, String envp[], File dir)
3.exec(String cmd, &n ......
xml文件如下 配置功能开关
<Configurations>
<Samples>true</Samples>
<Excepts>true</Excepts>
<CheckFace>false</CheckFace>
<ThumbNail>false</ThumbNail>
&nbs ......
#include <iostream>
using namespace std;
class Base {
public:
virtual void fn(int x) {
cout << "In Base class, int x = " << x << endl;
}
};
class SubClass : public Base {
public:
// 函数的重载,这样的重载方式,在Java中能行,在C/C++中却不行
virt ......
POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream(cfname));
HSSFWorkbook wb = new HSSFWorkbook(fs);
......
public static String splitAndFilterString(String input, int length) {
if (input == null || input.trim().equals("")) {
&nb ......