1.网页实现效果为
@WebServlet("captche")
public class CaptcheController extends HttpServlet {
@Override //resp给客户的 rep给服务器
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
ServletOutputStream sos=resp.getOutputStream();//输出数据通道
ImageIO.write(generatePic(100,40),"JPEG",sos);//借助ImaheIO类 生成一张格式为JPEG的图片
sos.flush();//解决缓冲区的数据
sos.close()