Gly*_*lyn 1 java eclipse gwt google-plugin-eclipse
我刚安装了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 Toolkit问题"
我下载了GWT 2.6 zip,然后将目录"GWT-2.6.0"复制到"Eclipse\eclipse-jee-juno-SR1-win32\eclipse\plugins"中.然后我右键单击该项目并选择"properties/Google/Web Toolkit/Configure SDKs .../Add".然后我浏览了"GWT-2.6.0"目录,添加并选中它.
我按照Braj的解决方案,并在重新编译时收到以下错误:
编译模块org.AwardTracker.AwardTracker验证单元:在第一遍中忽略了2个带有编译错误的单元.使用-strict或-logLevel进行编译设置为TRACE或DEBUG以查看所有错误.计算'gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl'的所有可能重新绑定结果重新绑定gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl无法找到完全匹配规则.使用基于后退值的"最接近"规则.您可能需要实现特定绑定,以防后备行为不替换'gwtupload/client/DecoratedFileUpload.java'中缺少的绑定[错误]错误[错误]第347行:重新绑定结果'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 + ">";
Run Code Online (Sandbox Code Playgroud)
其余代码是:
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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我只是评论了这一行("protected static final String XML_ERROR_ITEM_NOT_FOUND ="<"+ TAG_ERROR +"> item not found";"),重新编译并运行它,它工作正常.我希望这一切都有助于他人.感谢Braj的帮助.
每当您更改 GWT 版本时,您都必须从先前 GWT 版本自动生成的存根中清除您的项目,如下面的屏幕截图所示。
问题:文件war\WEB-INF\lib\gwt-servlet.jar的大小与 GWT SDK 库不同gwt-servlet.jar;也许它是一个不同的版本?
解决方案:您的问题gwt-servlet.jar是由以前的 GWT 版本自动生成的。只需将其与其他存根一起删除并再次重新编译项目。

| 归档时间: |
|
| 查看次数: |
4332 次 |
| 最近记录: |