0

安装 Mac OSX 10.6.7、Eclipse、Tomcat 1.6

我正在尝试将 Java 文件中的字符串调用到我的 JSP 以将其显示给用户,但我不断收到以下错误。一如既往地感谢任何帮助,

JSP

<%
Injector injector = Guice.createInjector(new GuiceInjector());
SliceConnector r = injector.getInstance(SliceConnector.class);  
out.println(r.search());    

String dbConcept = "http://dbpedia.org/resource/human_rights";
System.out.println(r.search(dbConcept));
%>

爪哇

public String search(String dbConcept)
{
    setSlicepediaProductionMode(true);

    List<SliceHit> sliceHits = searchForSlices();
    if (sliceHits == null) {
        System.err.println("Timeout occurred while fetching slices");
        return "error";
    }
    if (!sliceHits.isEmpty()) {
        System.out.println("Found some slices Yuhuuuu ! :-) ");
        String sliceContent = createSlices(sliceHits);
        System.out.println("Slice content:");
        System.out.println(sliceContent);
        return sliceContent;
    } else {
        System.out.println("No Slices were found for this query");
    }
    System.out.println("Slice Consumer stopped activity");      
    return "SliceConnector";
}

private void setSlicepediaProductionMode(boolean productionMode)
{
    sliceSearcher.setProductionMode(productionMode);
    sliceCreator.setProductionMode(productionMode);
}
private List<SliceHit> searchForSlices() {
    SlicepediaQuery sliceQuery = new SlicepediaQuery();

    String dbConcept = "http://dbpedia.org/resource/human_rights";

    sliceSearcher.setSliceQuery(sliceQuery);
    if (sliceSearcher.run()) 
    {
        return sliceSearcher.getSliceHits();
    } else 
    {
        return null;
    }
}

错误

exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 141 in the jsp file: /SimpleResponse2.jsp
The method search() in the type SliceConnector is not applicable for the arguments (String)
138:            
139:            
140:        String dbConcept = "http://dbpedia.org/resource/human_rights";
141:        System.out.println(r.search(dbConcept));
4

1 回答 1

1

我看到您调用了 search() 两次,第一次没有参数,第二次使用字符串。在发布的代码中,您仅提供后一种情况,因此您应该在第一次调用时已经收到错误。

更正第一次调用并确保您引用了正确的文件。

于 2012-06-20T19:49:52.010 回答