日期:2014-05-20  浏览次数:20849 次

struts2+jasperreport传值问题。
struts2怎么向 jasperreport里面矩形图传值。如下图,我是这样传的,但是运行的时候出现了
java.lang.reflect.InvocationTargetException异常。










通过测试。没有矩形图的时候,红色椭圆型类的字段可以显示起来。但是加上矩形图。就出现上面的异常情况了。怎么解决。

-------------------------------------------------
这是我的struts2测试代码
public class WangAction extends ActionSupport {
public List student;

public List getStudent() {
student = new ArrayList();
for(int i =0;i<4;i++){
Wang wang = new Wang(18+i,"***"+i);
student.add(wang);
}
return student;
}

public String execute() throws Exception {
String sourceFile = ServletActionContext.getServletContext().getRealPath("/Jasper/list.jrxml");

File parent = new File(sourceFile).getParentFile();

JasperCompileManager.compileReportToFile(sourceFile, new File(parent,"/list.jasper").getAbsolutePath());
return super.execute();
}

}-----------------------------------------------------
这是bean

public class Wang {
private String name;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public Wang(int age, String name) {
this.age = age;
this.name = name;
}
public void setAge(int age) {
this.age = age;
}

}------------------------

够详细了吧。


------解决方案--------------------
这么勤奋
顶你
------解决方案--------------------
....纯接分吧,如果可能,楼主可以把解决方法写成博客……
------解决方案--------------------
Study.楼主把答案发上来学习下。