JasperReports API:调用JasperCompileManager.compileReport(String)方法引发了MalformedByteSequenceException异常 [英] JasperReports API: calling JasperCompileManager.compileReport (String) method raised the MalformedByteSequenceException exception

查看:781
本文介绍了JasperReports API:调用JasperCompileManager.compileReport(String)方法引发了MalformedByteSequenceException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void openReport() {

    try {
        HashMap params = new HashMap();
        params.put("aapor", 19);

        JasperReport jasperReport1 = JasperCompileManager.compileReport("C:/Users/emidemi.emidemi-PC/Documents/NetBeansProjects/FleetManager/src/FleetManager/newReport5.jasper");
        JasperPrint jasperPrint1 = JasperFillManager.fillReport(jasperReport1, params, conn.getConn());

        JRViewer viewer = new JRViewer(jasperPrint1);

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

以上是我的脚本。

这是我的错误:

com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
BUILD SUCCESSFUL (total time: 7 seconds)

有谁知道为什么会这样,如何解决?

Does anyone know why this is occurring and how to fix it?

推荐答案

这是字符编码的问题。您是否尝试在报告开头更改编码行?

It's a problem with the character codification. Have you tried changing the encoding line at the beginning of the report?

即。对于中欧字母,更改:

i.e. for central european alphabet, change:

<?xml version="1.0" encoding="UTF-8"?>

by

<?xml version="1.0" encoding="CP1250"?>

这里有一个不同的字符编码标准列表:
http://en.wikipedia.org/wiki/Character_encoding#Common_character_encodings

You have a list of different character encoding standards here: http://en.wikipedia.org/wiki/Character_encoding#Common_character_encodings

希望它有效

这篇关于JasperReports API:调用JasperCompileManager.compileReport(String)方法引发了MalformedByteSequenceException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆