1

GWT 2.6 をインストールしたところ、「説明 リソース パス ロケーション タイプ ファイル war\WEB-INF\lib\gwt-servlet.jar のサイズが GWT SDK ライブラリ gwt-servlet.jar と異なります。おそらく別のバージョン? gwt-servlet.jar /AwardTracker/war/WEB-INF/lib 不明な Google Web ツールキットの問題"

GWT 2.6 zip をダウンロードし、ディレクトリ「GWT-2.6.0」を「Eclipse\eclipse-jee-juno-SR1-win32\eclipse\plugins」にコピーしました。次に、プロジェクトを右クリックして、[プロパティ/Google/Web Toolkit/Configure SDKs.../Add] を選択しました。次に、「GWT-2.6.0」ディレクトリを参照し、追加して選択しました。


Braj の解決策に従いましたが、再コンパイルすると次のエラーが発生しました。

コンパイル モジュール org.AwardTracker.AwardTracker ユニットの検証: 最初のパスでコンパイル エラーが発生した 2 つのユニットが無視されました。-strict または -logLevel を TRACE または DEBUG に設定してコンパイルすると、すべてのエラーが表示されます。「gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl」のすべての可能な再バインド結果を計算しています フォールバック値に基づく「最も近い」ルールの使用。フォールバック動作が欠落しているバインディングを置き換えない場合、特定のバインディングを実装する必要があるかもしれません' は抽象化できません

上記の問題は、gwtupload-1.0.1.jar をダウンロードし、「Add External JARS」を使用してライブラリに追加し、古い gwtupload-0.6.6.jar を削除することで修正されました。その後、再コンパイルしてコンパイル作業を行いました。ただし、「MyCustomisedUploadServlet」行にエラーがあります (このエラーは以前は存在しませんでした)。

 protected static final String XML_ERROR_ITEM_NOT_FOUND = "<" + TAG_ERROR + ">item not found</" + TAG_ERROR + ">";

コードの残りの部分は次のとおりです。

package org.AwardTracker.server;

import gwtupload.server.UploadAction;
import gwtupload.server.exceptions.UploadActionException;
import gwtupload.shared.UConsts;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Hashtable;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;

/**
 * This is an example of how to use UploadAction class.
 *  
 * This servlet saves all received files in a temporary folder, 
 * and deletes them when the user sends a remove request.
 * 
 * @author Manolo Carrasco Moñino
 *
 */
public class MyCustomisedUploadServlet extends UploadAction {

  private static final long serialVersionUID = 1L;
  protected static final String XML_ERROR_ITEM_NOT_FOUND = "<" + TAG_ERROR + ">item not found</" + TAG_ERROR + ">";

  Hashtable<String, String> receivedContentTypes = new Hashtable<String, String>();
  /**
   * Maintain a list with received files and their content types. 
   */
  Hashtable<String, File> receivedFiles = new Hashtable<String, File>();

  /**
   * Override executeAction to save the received files in a custom place
   * and delete this items from session.  
   */
  @Override
  public String executeAction(HttpServletRequest request, List<FileItem> sessionFiles) throws UploadActionException {
    String response = "";
    @SuppressWarnings("unused")
    int cont = 0;
    for (FileItem item : sessionFiles) {
      if (false == item.isFormField()) {
        cont ++;
        try {

          /// Create a temporary file placed in the default system temp folder
          File file = File.createTempFile("upload-", ".bin");
          item.write(file);

          /// Save a list with the received files
          receivedFiles.put(item.getFieldName(), file);
          receivedContentTypes.put(item.getFieldName(), item.getContentType());

          /// Send a customised message to the client.
          response += file.getAbsolutePath();

        } catch (Exception e) {
          throw new UploadActionException(e);
        }
      }
    }

    /// Remove files from session because we have a copy of them
    removeSessionFileItems(request);

    /// Send your customised message to the client.
    return response;
  }

  /**
   * Get the content of an uploaded file.
   */
  @Override
  public void getUploadedFile(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String fieldName = request.getParameter(UConsts.PARAM_SHOW);
    File f = receivedFiles.get(fieldName);
    if (f != null) {
      response.setContentType(receivedContentTypes.get(fieldName));
      FileInputStream is = new FileInputStream(f);
      copyFromInputStreamToOutputStream(is, response.getOutputStream());
    } else {
      renderXmlResponse(request, response, XML_ERROR_ITEM_NOT_FOUND);
   }
  }

  /**
   * Remove a file when the user sends a delete request.
   */
  @Override
  public void removeItem(HttpServletRequest request, String fieldName)  throws UploadActionException {
    File file = receivedFiles.get(fieldName);
    receivedFiles.remove(fieldName);
    receivedContentTypes.remove(fieldName);
    if (file != null) {
      file.delete();
    }
  }
}

この行を単にコメントアウトし (" protected static final String XML_ERROR_ITEM_NOT_FOUND = "<" + TAG_ERROR + ">item not found";")、再コンパイルして実行したところ、正常に動作しました。これがすべて他の人に役立つことを願っています。ブラジの助けに感謝します。

4

4 に答える 4

7

これは私にとって非常にうまく機能します

警告を選択し、右クリックして [クイック修正] -> [/WEB-INF/lib を SDK ライブラリと同期] を選択します。

"終わり"

于 2015-05-08T08:17:34.740 に答える
2

SDK をプラグイン ディレクトリにコピーすることは、別の SDK バージョンを追加する正しい方法ではありません。

Preferences -> Google -> Web Toolkit を使用して、別の GWT SDK バージョンを追加します。

プロジェクトで次を選択します。

プロジェクト プロパティ -> Goolge -> Web Toolkit で、プロジェクトが使用する SDK を選択できます。

于 2014-05-04T11:50:55.013 に答える
0

コンパイラを 1.8 から 1.7 に変更したところ、このメッセージが表示されなくなりました。

于 2014-11-04T19:59:57.460 に答える