jasperreport集成spring为什么启动不了服务器
controller层package controller;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.PersonBeanFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class JasperSpringController implements Controller {
//视图名称
String viewName = "易做图Report";
//重写Controller接口handleRequest方法
@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
return new ModelAndView(viewName, getModel());
}
private Map getModel() throws Exception
{
Map model = new HashMap();
Collection beanData = (new PersonBeanFactory()).getPersons();
model.put("PersonBean", beanData);
return model;
}
}
model
package model;
import java.io.Serializable;
public class PersonBean implements Serializable {
private String ID;
private String name;
private String address;
private double salary;
public PersonBean() {
}
public PersonBean(String id, String name, String address, double salary) {
this.ID = id;
this.name = name;
this.address = address;
this.salary = salary;
}
public String getID() {
return ID;
}
public void setID(String id) {
ID = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
}
package model;
import java.util.ArrayList;
import java.util.List;
public class PersonBeanFactory {
List<PersonBean> persons = new ArrayList<PersonBean>();
// 获得人员,作为报表的数据源
public List getPersons() {
for (int i = 0; i < 10; i++) {
persons.add(new PersonBean("1" + i, "name" + i, "address" + i, Math.random()* 100 + i));
}
return persons;
}
}
补充:Java , Java相关