我尝试使用称为J-Calais的API的get结果,然后将结果放在网页上,我在客户端中编写所有代码,但是它不能正确编译,不知道为什么???请帮忙。源代码如下:

没有明显的错误,但不能成功地编译.....非常感谢:

public void onmoduleload(){//创建用于库存数据的表。 Stocksflextable.setText(0,0,“ type”); Stocksflextable.setText(0,1,“名称”);

// Assemble Add Stock panel.
addPanel.add(newSymbolTextBox);
addPanel.add(addStockButton);

// Assemble Main panel.
mainPanel.add(stocksFlexTable);
mainPanel.add(addPanel);
mainPanel.add(lastUpdatedLabel);

// Associate the Main panel with the HTML host page.
RootPanel.get("stockList").add(mainPanel);

// Move cursor focus to the input box.
newSymbolTextBox.setFocus(true);

//收听添加按钮上的鼠标事件。 addstockbutton.addclickhandler(new ClickHandler(){public void onClick(clickevent event){

                        try {
                            addStock();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

  }
});
// Listen for keyboard events in the input box.
newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() {
  public void onKeyPress(KeyPressEvent event) {
    if (event.getCharCode() == KeyCodes.KEY_ENTER) {  
            try {
                addStock();
            } catch (Exception e) {
                e.printStackTrace();
            }
  }
  }
});

}

private void addStock() throws Exception {
  final String url_s = newSymbolTextBox.getText().toUpperCase().trim();
  newSymbolTextBox.setFocus(true);
  newSymbolTextBox.setText("");
  int row = stocksFlexTable.getRowCount();


  CalaisClient client = new CalaisRestClient("ysw5rx69jkvdnzqf6sgjduqj");
    System.out.print("read success...\n");
     URL url = new URL(url_s);    
     CalaisResponse response = client.analyze(url);         
        for (CalaisObject entity : response.getEntities()) {
            System.out.println(entity.getField("_type") + ":" 
                               + entity.getField("name"));
            stocks.add(entity.getField("_type"));
            stocksFlexTable.setText(row, 0, entity.getField("_type"));
            stocksFlexTable.setText(row, 1, entity.getField("name"));
          }

        for (CalaisObject topic : response.getTopics()) {
            System.out.println(topic.getField("categoryName"));
          }

}

}

有帮助吗?

解决方案

GWT只能处理 未选中的例外 所以你可以扔 运行时异常

或写自己的例外 扩展 从运行时例外,它不会引起任何编译时间问题

void f() throws NullPointerException // will not cause any problem because it is Runtime exception so unchecked

void f() throws IllegalAccessException // it is checked exception so there will be problem at compile time
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top