가장 먼저 해야할것은 Vo부터 선언해야합니다.
 
@Data
public class TestVo {
    private String test_date;
    private String name;
    private String status;
    private String no1;
    private String no2;
    private String memo;
}

 

그 이후 Controller부분 입니다.

 
@Component("testReport")
@SuppressWarnings("unchecked")
public class TestReport extends AbstractView {

    @Autowired
    TestReportService testReportService;
   
    @Override
    protected void testModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws BizException, Exception {
        ServletOutputStream os = null;
       
        try {
            log.debug(">>>레포트 생성 START");

            // jasper 위치
            InputStream inputStream = new ClassPathResource("report/test.jasper").getInputStream();
           
            List<TestVo> testList = testReportService.getTestInfo(model);
 
            // allParams
            Map<String, Object> allParams = new HashMap<>();
           
            allParams.put("list", testList);
           
            // data source
            JRDataSource dataSource = testList.size() > 0 ? getDataSource(testList) : new JREmptyDataSource(1);
           
            log.debug(">>>>>>>>>> fill report START");
            JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, allParams, dataSource);
            log.debug(">>>>>>>>>> fill report END");
           
            JRPdfExporter exporter = new JRPdfExporter(DefaultJasperReportsContext.getInstance());
            exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
           
            os = response.getOutputStream();
            exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(os));
            response.setContentType("application/pdf");
           
            String fileName = URLEncoder.encode("테스트", "UTF-8").replace("+", "%20");
            SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
            configuration.setMetadataTitle("테스트");

            response.setHeader("Content-Disposition", "inline; filename=\"" + fileName + ".pdf\"");
           
            configuration.setPdfVersion(PdfVersionEnum.VERSION_1_7);
            exporter.setConfiguration(configuration);
           
            log.debug(">>>>>>>>>> export pdf START");
            exporter.exportReport();
            log.debug(">>>>>>>>>> export pdf END");
           
        } catch(BizException e) {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);  // 400 오류
            log.error(e.getMessage(), e);
        } catch(NullPointerException | IOException e) {
            log.error(e.getMessage(), e);
        } catch(Exception e) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            log.error(e.getMessage(), e);
        } finally {
            if (os != null) {
                try {
                    os.flush();
                    os.close();
                } catch(IOException e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
    }

    private JRDataSource getDataSource(List<TestVo> rates) {

        return new JRBeanCollectionDataSource(rates);
    }
}

 

Service 부분 입니다.

public List<TestVo> getTestInfo(Map<String, Object> paraMap) {
        return testReportMapper.slctTestInfo(paraMap);
}

 

Mapper 부분 입니다.

public List<TestVo> slctTestInfo(Map<String, Object> paraMap);

 

xml 부분에서는 resultType만 Vo로 해주면 됩니다.

<select id="slctTestInfo"  parameterType="hashmap" resultType="com.kadra.asms.report.web.vo.CertCancelVo">
</select>