- 博客(6)
- 收藏
- 关注
原创 验证码的生成
public class TextCode { static int height = 40; static int width = 90; static int codesize = 4; static char[] codeSequence = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R','S', 'T', 'U', 'V',...
2022-03-06 20:07:52 53
原创 使用流转存文件
InputStream is = new FileInputStream(file); OutputStream os = new FileOutputStream("D:\\远程桌面\\"+file.getName()); byte[] b = new byte[1024]; while(is.read(b)!=-1) { os.write(b); } os.close(); is.cl...
2022-02-24 15:34:44 245
原创 使用PageHelper进行分页
Service层: public void buildPage(HttpServletRequest request) { int pageNum = 1; int pageSize = 9; try { pageNum = Integer.parseInt(request.getParameter("pageNum")); pageSize = Integer.parseInt(request.getParameter("pageSize"));
2021-11-21 15:43:05 377
原创 数据库中的图片使用Base64显示
model.addAttribute("photo", "data:image/jpeg;base64," + Base64.getEncoder().encodeToString(photo) ); photo为从数据库中得到的流
2021-11-21 15:34:59 554
原创 图片/文件的上传
这里演示为图片的上传 public byte[] FileUpload(MultipartFile files) throws IOException { //选择一个路径 File path = new File("D:\\Study\\JavaWeb\\实训\\demo"); //将文件转存在该路径下,files.getOriginalFilename()为文件的源名字 files.transferTo(new File(path + "\\" +files.getO
2021-11-21 15:31:08 306
原创 List.add报空指针错误
原先代码: List<String> photo = null; for (Merchants merchant : merchants){ if (merchant.getPhoto() != null){ photo.add("data:image/jpeg;base64," + Base64.getEncoder().encodeToString(merchant.getPhoto())); } } 结果报空指针错误,因为list创建的时候没有指向一个
2021-11-18 15:57:58 306
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人