JavaWeb学习笔记3——生成图片验证码,今日头条java后端面试怎么样

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip1024b (备注Java)
img

正文

//获取6位随机字符验证码的方法

public static String getRandomString(){

StringBuffer buffer=new StringBuffer();

for(int i=0;i<6;i++){

buffer.append(CHARS[random.nextInt(CHARS.length)]);

}

return buffer.toString();

}

//随机颜色

public static Color getRandomColor(){

return new Color(random.nextInt(255),random.nextInt(255),random.nextInt(255));

}

//某颜色的反色,用于前景色

public static Color getReverseColor(Color c){

return new Color(255-c.getRed(),255-c.getGreen(),255-c.getBlue());

}

/**

  • Constructor of the object.

*/

public IdentityServlet() {

super();

}

/**

  • Destruction of the servlet.

*/

public void destroy() {

super.destroy(); // Just puts “destroy” string in log

// Put your code here

}

/**

  • The doGet method of the servlet.

  • This method is called when a form has its tag value method equals to get.

  • @param request the request send by the client to the server

  • @param response the response send by the server to the client

  • @throws ServletException if an error occurred

  • @throws IOException if an error occurred

*/

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

response.setContentType(“image/jpeg”);

String randomString=getRandomString(); //随机字符串

request.getSession(true).setAttribute(“randomString”, randomString);

int width=100;

int height=30;

Color color=getRandomColor();

Color reverse=getReverseColor(color); //反色,用于前景色

BufferedImage bi=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);

Graphics2D g=bi.createGraphics();

g.setFont(new Font(Font.SANS_SERIF,Font.BOLD,16));

g.setColor(color);

g.fillRect(0, 0, width, height);

g.setColor(reverse);

g.drawString(randomString, 18, 20); //绘制随机字符

for(int i=0, n=random.nextInt(100);i<n;i++){

//画最多100个噪音点

g.drawRect(random.nextInt(width), random.nextInt(height), 1, 1); //噪音点在图片上随机选择位置产生

}

ServletOutputStream out=response.getOutputStream();

JPEGImageEncoder encoder=JPEGCodec.createJPEGEncoder(out); //转成JPEG格式

encoder.encode(bi); //对图片进行编码

out.flush();

}

/**

  • The doPost method of the servlet.

  • This method is called when a form has its tag value method equals to post.

  • @param request the request send by the client to the server

  • @param response the response send by the server to the client

  • @throws ServletException if an error occurred

  • @throws IOException if an error occurred

*/

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

response.setContentType(“text/html”);

PrintWriter out = response.getWriter();

out.println(“”);

out.println(“”);

out.println(" A Servlet");

out.println(" ");

out.print(" This is ");

out.print(this.getClass());

out.println(“, using the POST method”);

out.println(" ");

out.println(“”);

out.flush();

完结

Redis基于内存,常用作于缓存的一种技术,并且Redis存储的方式是以key-value的形式。Redis是如今互联网技术架构中,使用最广泛的缓存,在工作中常常会使用到。Redis也是中高级后端工程师技术面试中,面试官最喜欢问的问题之一,因此作为Java开发者,Redis是我们必须要掌握的。

Redis 是 NoSQL 数据库领域的佼佼者,如果你需要了解 Redis 是如何实现高并发、海量数据存储的,那么这份腾讯专家手敲《Redis源码日志笔记》将会是你的最佳选择。

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
img

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
[外链图片转存中…(img-KBHFsY5A-1713612163626)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值