1

听说这是我的学生 pojo 课...

 public class Student {

 private int id;

 private String name;

 private String address;

 private String gender;

 private String emailId;

 private String contactNo;
//setter getter

我将在下面开发一个学生列表类:

public class StudentList {

@XmlElement
private List<Student> slist ;

public StudentList(List<Student> slist){
    this.slist= slist;
}//setter getter

我的学生服务课程如下:

  public class StudentService extends Application {
@GET
@Path("student/read") 
@Produces("application/json")      
@GZIP  public StudentList readstudent(@Context HttpServletRequest request){

    StudentList slistDetail = new StudentList();

    List<Student> s = new ArrayList<Student>();

    for(int i=0; i<50; i++)
    {
        Student st = new Student();
        st.setId(i);
        st.setName("name "+ i);
        st.setAddress("address "+ i);
        st.setContactNo("12345"+i);
        st.setEmailId("email"+i+"@gmail.com");
        st.setGender("m");

        s.add(st);
    }
    slistDetail.setSlist(s);
    return slistDetail;
}

Web.xml`

<context-param>
  <param-name>javax.ws.rs.core.Application</param-name>
  <param-value>com.service.StudentService</param-value>

 <listener>
  <listener-class>
     org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
  </listener-class>

<servlet>
  <servlet-name>Resteasy</servlet-name>
  <servlet-class>
     org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
  </servlet-class>

我会发现以下错误:

java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Unknown Source)
at java.util.jar.Manifest.read(Unknown Source)
at java.util.jar.Manifest.<init>(Unknown Source).....

所以,请告诉我为什么会发生这种类型的错误......提前谢谢

4

0 回答 0