해시 테이블에서 사용자가 입력하는 articleName에 대한 authorID를 검색하는 방법을 만들려고합니다. 이 포함 된 클래스 코드는텍스트 상자에 인쇄하지 않습니다.
public int sendAuthorID(String articleNameRequest) {
// get info from the hashtable
aNumber = (Integer) theHashtable.getAuthorID(articleNameRequest); // was this.
return aNumber;
}
: 서버 측에서 상기 방법은
public String getAuthorID() // returns a String
{
try
{
articleName = txtArticleName.getText();
argAuthorID = new Vector();// create vector for the args
argAuthorID.addElement(articleName);// name to search for to get AuthorID
// make the call to the server
authorIDVector = (Integer)client.execute("GetSize.sendAuthorID", argAuthorID);
System.out.println(argAuthorID);
}
catch (XmlRpcException exception) {
System.err.println("JavaClient: XML-RPC Consumer Fault #" +
Integer.toString(exception.code) + ": " +
exception.getCause() + "" + exception.toString());
} catch (Exception exception) {
System.err.println("JavaClient: XML-RPC Consumer Fault #" + exception.toString());
}
String StrAuthorID = Integer.toString(authorID); // Cast AuthorID to String
return StrAuthorID;
}
이다 : 사용자가 버튼을 눌렀을 때 여기에서 클라이언트 측에서 활성화 코드는 해시 테이블 :
public int getAuthorID(String articleName)
{
int intfoundit;
String foundit = (String)hashtab.get(articleName);
System.out.print(foundit);
intfoundit = Integer.parseInt(foundit);
System.out.print(foundit);
System.out.print(intfoundit);
return intfoundit;
}
프로그램은 AuthorID를 검색 할 수 있지만 입력란에는 입력하지 않습니다. 테스트를 통해 나는 예외가이 코드에 의해 발생 된 것을 발견 :
'JavaClient : XML-RPC 소비자 오류 # 0 : nullorg.apache
catch (XmlRpcException exception) { System.err.println("JavaClient: XML-RPC Consumer Fault #" + Integer.toString(exception.code) + ": " + exception.getCause() + "" + exception.toString());
이 부여되는 오류입니다. xmlrpc.XmlRpcException : java.lang.Exception가 : java.lang.NumberFormatException의 : 입력 문자열 : "3377" '
업데이트 : 해시 테이블에있는 ID 번호 앞에 공간을 제거하고 포기하지 않는 오류 anym 광석을 입력했지만 여전히 입력란에 ID 번호가 입력되지 않고 '0'이 입력됩니다.
방금 문제를 해결했지만 방법이 실제로 어떤 이유로 든 ID 번호를 반환하지 않는 것 같습니다. –