136. } 137. 138. return "checkacode"; 139. } 140. 141. 142. 143. 144./** 145. * ****************** * Action生成验证码* ****************** 146. */ 147. private Font imgFont = new Font("Times New Roman", Font.BOLD, 17); 148. 149. Color getRandColor(int fc, int bc) { 150. 151. Random random = new Random(); 152. 153. if (fc > 255) { 154. 155. fc = 255; 156. 157. } 158. 159. if (bc > 255) { 160. 161. bc = 255; 162. 163. } 164. 165. int r = fc + random.nextInt(bc - fc); 166. 167. int g = fc + random.nextInt(bc - fc); 168. 169. int b = fc + random.nextInt(bc - fc); 170. 171. return new Color(r, g, b); 172. 173. } 174. 175. public void checkCodeImage() { 176. 177. HttpServletRequest request = ServletActionContext.getRequest(); 178. 179. HttpServletResponse response = ServletActionContext.getResponse(); 180. 181. response.setHeader("Pragma", "No-cache"); 182. 183. response.setHeader("Cache-Control", "no-cache"); 184. 185. response.setDateHeader("Expires", 0); 186. 187. response.setContentType("image/jpeg"); 188. 189. int width = 75, height = 20; 190. 191. BufferedImage image = new BufferedImage(width, height, 192. 193. BufferedImage.TYPE_INT_RGB); 194. 195. Graphi上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>
|