报表开发整合到WE中问题
报错:没有找到数据源
java.lang.RuntimeException: No dataSource specified...
我用的是IReport3.0.0 这个2个文件后缀名怎么是这样子的
Action代码:
public class Action extends ActionSupport{
private static final long serverID=1L;
private static Connection connection = null;
private static PreparedStatement pstm = null;
private static ResultSet rs = null;
private static final String Drive = "com.mysql.jdbc.Driver";
private static final String URL ="jdbc:mysql://localhost:3306/mysql";
private static String sql = "";
List list = new ArrayList();
public void setList(List list) {
this.list = list;
}
public String execute() throws Exception {
Class.forName(Drive);
connection = DriverManager.getConnection(URL,"root","a123");
sql="select * from test";
pstm=connection.prepareStatement(sql);
rs=pstm.executeQuery();
while(rs.next()){
Test test = new Test();
test.setId(rs.getInt("id"));
test.setName(rs.getString("name"));
list.add(test);
}
return SUCCESS;
}
public List getList() {
return list;
}
StrutsXML:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="struts" namespace="/" extends="struts-default,jasperreports-default">
<action name="yx" class="com.Action">
<result type="jasper">
<param name="location">
/jasper/Untitled_report_2.jrxml
</param>
<param name="dataSouse">list</param>
<param name="format">{1}</param>
</result>
</action>
</package>
</struts>
------解决方案--------------------
请放入编译后的.jasper文件。在ireport中,你还得配置数据源。至于是数据库还是javabean或者是Excel,LZ自己选择。
贴下以前做的,做的可能不怎么好。
<!--struts配置-->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts