首页 > 代码库 > web server(protein protection )搭建过程中遇到的问题
web server(protein protection )搭建过程中遇到的问题
1、StringBuffer中append方法有错误
原因分析:是project默认的JRE系统库和配置的jre不匹配。
解决方法:项目属性->Add Libray->JRE System Library->Alternate JRE(选择Sun JDK 1.6.0_13)
2、文件上传问题
mySmartUpload.setAllowedFilesList("txt"); //设置上传文件类型只能是txt格式
文件上传处理过程
- jsp文件:
<div id="input" align="center" style="width:900px;"> <p>Please select file <input type="file" name="uploadFile" id="file"> </div>
- servlet文件:
PrintWriter out=response.getWriter(); String wrongmessage = "success!"; SmartUpload mySmartUpload=new SmartUpload(); mySmartUpload.initialize(config, request, response); mySmartUpload.setMaxFileSize(1024*2048); //mySmartUpload.setAllowedFilesList("txt"); //bebug int j = 0; try { mySmartUpload.upload(); for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) { ++j; com.jspsmart.upload.File file = mySmartUpload.getFiles().getFile(i); if (file.isMissing()) continue; } }catch(Exception err) { wrongmessage="error in upload " + err.getMessage() + " File:"+j+" in line 251"; //out.println("error in upload"+err.getMessage()); //allright=false; //return; } out.print(wrongmessage+" num: " + j); }
3、提示错误,serialVersionUID冲突。
java.io.InvalidClassException: message.RegisterMessage; local class incompatible: stream classdesc serialVersionUID = 5540404719929042644, local class serialVersionUID = -8915824483106432775
serialVersionUID的详细介绍:http://www.cnblogs.com/guanghuiqq/archive/2012/07/18/2597036.html
解决方法:
如果不想定义它,在Eclipse的设置中也可以把它关掉的,设置如下:
Window ==> Preferences ==> Java ==> Compiler ==> Error/Warnings ==>Potential programming problems
将Serializable class without serialVersionUID的warning改成ignore即可。
2014-09-20
本文内容遵从CC3.0版权协议,转载请注明:转自学而优,思则通
本文链接地址:web server(protein protection )搭建过程中遇到的问题web server(protein protection )搭建过程中遇到的问题