大家好!我使用Linux + Tomcat + MyEclipse 基于Web Service的web 服务。我在一个jsp文件中 调用Web Service,再将Web Service 返回的内容,以网页的形式返回给用户。Web Service 返回的内容是放在List<DataBaseRecord>列表中的。但在jsp文件中观察Web Service 返回的列表中包含的对象数目是正确的,但,每个对象的内容是空的。 web service 的方法叫 WelcomeYou定义如下:[Code]
public List<DataBaseRecord> WelcomeYou(String ExampleDoc)
{
   List<DataBaseRecord> RetrievalResult = new ArrayList<DataBaseRecord>();
   
  //  Search relevant documents according to 'ExampleDoc' from a database
  //  The search result will be put into a RecordSet object 'rs'   while(rs.next())
  {
              DataBaseRecord  NewRecord = new DataBaseRecord ();
              NewRecord.RetrievedDocID = rs.getString("RetrievalDocID");
              NewRecord.SimiScore =  Float.valueof(rs.getString("SimiScore"));              RetrievalResult.add(NewRecord );  }
// I use the following for loop to see the content of RetrievalResult. I can see that the content is just what I expect. Additionally, the size of RetrievalResult is correct too.
for(DataBaseRecord   databaserecord : RetrievalResult)
{
     System.out.println(databaserecord.RetrievedDocID + databaserecord.SimiScore);
}  return RetrievalResult;
[/code]调用WelcomeYou方法的jsp文件部分内容如下, [Code]
List<DataBaseRecord>  Result = new List<DataBaseRecord>();
Result = srvc.WelcomeYou("some text ");// I use the following for loop to see the content of Result, but each element of Result is empty. Moreover, the strange thing is that the size of Result is right.for(DataBaseRecord   databaserecord : Result)
{
     System.out.println(databaserecord.RetrievedDocID + databaserecord.SimiScore);
}the class DataBaseRecord is defined as follows
[/code]
类DataBaseRecord定义如下。
[Code]
public class DataBaseRecord{
    public String RetrievedDocID;
    public float SimiScore;
}
[/code]在WelcomeYou函数体的最后(就在语句 ' return RetrievalResult;' 之前), 利用一个for循环对RetrievalResult的内容进行了检查,其内容是对的.在 jsp 文件中, 在下面语句之后
[Code]  
 Result = srvc.WelcomeYou("some text ");
[/code]我检查了 Result 中的内容, Result 中的每一对象的内容都是空的,但Result中所含的对象的数目是对的。
请大家帮忙看看问题出在哪里, 谢谢