spring mvc 导出 excel 2021年8月31日 | Leave a comment 问题: 解决: package com.telsafe.crccdemo.rest; import org.apache.poi.ss.usermodel.CellType; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.view.document.AbstractXlsView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @Controller @RequestMapping("export") public class ExportController { final UserService userService; public ExportController(final UserService userService) { this.userService = userService; } @PostMapping("users") ModelAndView users(@RequestParam(value = "path", required = false) String path) { final var list = .../// new ArrayList<UserVo> return new ModelAndView(new UserXlsView(), Map.of("list", list)); } static class UserXlsView extends AbstractXlsView { @Override protected void buildExcelDocument(final Map<String, Object> map, final org.apache.poi.ss.usermodel.Workbook workbook, final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws Exception { Objects.requireNonNull(workbook); var sheet = workbook.createSheet(); final List<UserVo> users = (List<UserVo>) map.get("list"); for (int i = 0; i < users.size(); ++i) { final var user = users.get(i); final var row = sheet.createRow(i); var indexCell = row.createCell(0, CellType.NUMERIC); indexCell.setCellValue(user.getIndex()); row.createCell(1, CellType.STRING).setCellValue(user.getName()); row.createCell(2, CellType.STRING).setCellValue(user.getCompanyName()); row.createCell(3, CellType.STRING).setCellValue(user.getDepartmentName()); row.createCell(4, CellType.STRING).setCellValue(user.getPositionName()); } } } } 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 package com.telsafe.crccdemo.rest; import org.apache.poi.ss.usermodel.CellType;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.servlet.ModelAndView;import org.springframework.web.servlet.view.document.AbstractXlsView; import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.util.List;import java.util.Map;import java.util.Objects;import java.util.stream.Collectors; @Controller@RequestMapping("export")public class ExportController { final UserService userService; public ExportController(final UserService userService) { this.userService = userService; } @PostMapping("users") ModelAndView users(@RequestParam(value = "path", required = false) String path) { final var list = .../// new ArrayList<UserVo> return new ModelAndView(new UserXlsView(), Map.of("list", list)); } static class UserXlsView extends AbstractXlsView { @Override protected void buildExcelDocument(final Map<String, Object> map, final org.apache.poi.ss.usermodel.Workbook workbook, final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws Exception { Objects.requireNonNull(workbook); var sheet = workbook.createSheet(); final List<UserVo> users = (List<UserVo>) map.get("list"); for (int i = 0; i < users.size(); ++i) { final var user = users.get(i); final var row = sheet.createRow(i); var indexCell = row.createCell(0, CellType.NUMERIC); indexCell.setCellValue(user.getIndex()); row.createCell(1, CellType.STRING).setCellValue(user.getName()); row.createCell(2, CellType.STRING).setCellValue(user.getCompanyName()); row.createCell(3, CellType.STRING).setCellValue(user.getDepartmentName()); row.createCell(4, CellType.STRING).setCellValue(user.getPositionName()); } } }} … Read More
Spring Boot OpenID Connect 备忘 2021年8月25日 | Leave a comment 问题: SpringBoot 2.5.x 如何集成 OpenID Connect 登录 解决: … Read More
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 2021年8月25日 | Leave a comment 问题: Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141) ~[na:na] at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126) ~[na:na] at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297) ~[na:na] at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434) ~[na:na] ... 98 common frames omitted 123456 Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141) ~[na:na] at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126) ~[na:na] at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297) ~[na:na] at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434) ~[na:na] ... 98 common frames omitted &nbs… Read More
spring boot 中如何使用国产 CFCA 证书 2021年8月25日 | Leave a comment 问题: 虽然可以通过方式一导入 解决: 方式一: Java 导入CA 根证书 方式… Read More
转:Keycloak快速上手指南,只需10分钟即可接入Spring Boot/Vue前后端分离应用实现SSO单点登录 2021年8月24日 | Leave a comment https://www.cnblogs.com/vigoz/p/12984556.html &n… Read More
转:[认证 & 授权] 4. OIDC(OpenId Connect)身份认证(核心部分) 2021年8月24日 | Leave a comment https://www.cnblogs.com/linianhui/p/openid-connect-core… Read More
sqlserver 导入 mysql 备忘 2021年8月18日 | Leave a comment 问题: 同事导出了个sqlserver 的 sql 超大文件 1G 解决: 如果有条件还是用 m… Read More
一个不错的工具 Anaconda 2021年8月18日 | Leave a comment 在Windows上安装 python + conda + 各种数据包 还能直接用 JupyterLab… Read More