我在 jsp 中访问我的 java 类时遇到问题。
在jsp中:
<%@ page import="package.ClientWithResponseHandler" %>
<% ClientWithResponseHandler jira = new ClientWithResponseHandler();
System.out.println(jira.getJIRA()); %>
在java中:
public class ClientWithResponseHandler {
public String getJIRA() throws Exception {
String string="";
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("someURL");
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String[] responseBody = httpclient.execute(httpget, responseHandler).replace("[", "").replace("}]","").split("},");
for (int i=0;i<responseBody.length;i++)
{
responseBody[i]+="}";
JSONObject project= new JSONObject(responseBody[i]);
string +=project.getString("name");
string+="||";
String url=project.getString("self");
HttpGet httpget2 = new HttpGet(url);
String responseBody2 = httpclient.execute(httpget2, responseHandler);
JSONObject taskall= new JSONObject(responseBody2);
JSONArray tasks=taskall.getJSONArray("components");
for(int j=0;j<tasks.length();j++)
{
JSONObject task= tasks.getJSONObject(j);
string+=task.getString("name");
string+="|";
}
}
return string;
}
}
通过调用 getJIRA() 方法,我希望它返回我在进行休息调用时得到的数据字符串。我已经检查过了,我认为 java 类确实可以正常工作并返回一个字符串。当我运行我的 jsp 页面时,会引发异常:
HTTP Status 500 - An exception occurred processing JSP page /index.jsp at line 23
23: <% ClientWithResponseHandler jira = new ClientWithResponseHandler();
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/http/client/ResponseHandler
java.lang.NoClassDefFoundError: org/apache/http/client/ResponseHandler
java.lang.ClassNotFoundException: org.apache.http.client.ResponseHandler
我对编程很陌生,所以我不知道这意味着什么。如果有人可以帮助我,我将不胜感激。