http://www.json.org/json-zh.html
二.Download ajaxfileupload.js:
http://www.phpletter.com/DOWNLOAD/
三.code :
1.demoTestAction.java
------------------------------------------------------------------------------------------------------------------------
public ActionForward doUpload(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { String fileName= null; String filePatch = null; try{ if (actionForm instanceof UploadForm) { String encoding = request.getCharacterEncoding(); if ((encoding != null) && (encoding.equalsIgnoreCase("utf-8"))) { response.setContentType("text/html; charset=utf-8"); } UploadForm theForm = (UploadForm) actionForm; FormFile file = theForm.getTheFile(); System.out.println("file >>>>>>"+file); fileName= file.getFileName(); System.out.println("fileName >>>>>>"+fileName); if (file.getFileSize() > (1*1024000)) { return doError(response, "Upload file is too large"); } filePatch = createServerFile(file,request); } JSONObject json = new JSONObject(); json.put("isWait", filePatch); json.write(response.getWriter()); } catch (Exception e) { return doError(response, e.getMessage()); } return null; } </pre>//--end
2.demoTest.jsp
-----------------------------------------------------------------------------------------------------------------------
沒有留言:
張貼留言