checkcode.java.svn-base

来自「用JSP JAVA 做的 系统 只是初来扎到还望西黄!别乱来哦!」· SVN-BASE 代码 · 共 42 行

SVN-BASE
42
字号
/**
 * Copyright (c) 2005-2008 KIND Corp. 2005-2008,All Rights Reserved.
 * This software is published under the KIND Team.
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 *
 * @File name:  NoUseCAKeyLogon.java
 * @Description:   
 * @Create on:  2008-3-22
 * @Author   :  st
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 *
 */

package com.chis.model.frame;

import java.util.Random;
import com.stframe.form.ActionForm;
import com.stframe.servlet.ActionInstance;

public class CheckCode extends ActionInstance{	
	public int execute(ActionForm af) throws Exception {		 
		 Random random = new Random();
		 String rand =String.valueOf(random.nextInt(9999));
		 
		switch(rand.length()) 
		{	
			case 1: rand = "000"+rand; break; 
			case 2: rand = "00"+rand; break; 
			case 3: rand = "0"+rand; break; 
			default: rand = rand.substring(0,4); break; 
		} 
		
		 af.getHttpSession().setAttribute("CheckCode", rand );
		 return 1;
		}
	 
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?