struts2 + uploadify http错误302

时间:2013-04-21 11:38:13

标签: jquery struts2 uploadify swfobject swfupload

我正在尝试使用带有struts2的uploadify,当我选择一个文件显示时,http错误302.请有人指出我的问题。我认为它根本没有到达服务器,因为在开头本身没有print语句的输出。

JSP

<!DOCTYPE html>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<html lang="en">
    <head>
        <% 
            String sessionid = request.getSession().getId().toString();
            String path= request.getContextPath();
         %>
        <sj:head jqueryui="true" compressed="false"/>
        <title>Uploadify test</title>
        <script src="uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="uploadify/uploadify.css">
        <script type="text/javascript" id="015e9c19-de54-402c-8ce4-93a29d054dbc"><!--/*--><![CDATA[/*><!--*/
        $(document).ready(function(){
            var id='<%=sessionid%>';
            var path='<%=path%>';
            alert(id);
                $('#file_upload1').uploadify({
                        uploader:'uploads?jsessionid='+id, 
                        scriptAccess:'always', 
                        auto:true, 
                        multi:true, 
                        swf:'uploadify/uploadify.swf', 
                        cancelImg:'uploadify/uploadify-cancel.png',
                        onError : function(event, queueID, fileObj, errorObj) { alert(errorObj.type + ' ' + errorObj.info ); }
                });
        });
        /*-->]]>*/
    </script>

    </head>
    <body>
       <input name="file_upload" type="file" id="file_upload1"/>
       <a href="javascript:$('#file_upload1').uploadifyUpload();">Upload Files</a>
    </body>
</html>

动作

@Namespace("/")
public class UploadifyAction extends ActionSupport{

    private List<File> fileUpload = new ArrayList<File>();
    private List<String> fileUploadContentType = new ArrayList<String>();
    private List<String> fileUploadFileName = new ArrayList<String>();

    public List<File> getFileUpload() {
        return fileUpload;
    }

    public void setFileUpload(List<File> fileUpload) {
        this.fileUpload = fileUpload;
    }

    public List<String> getFileUploadContentType() {
        return fileUploadContentType;
    }

    public void setFileUploadContentType(List<String> fileUploadContentType) {
        this.fileUploadContentType = fileUploadContentType;
    }

    public List<String> getFileUploadFileName() {
        return fileUploadFileName;
    }

    public void setFileUploadFileName(List<String> fileUploadFileName) {
        this.fileUploadFileName = fileUploadFileName;
    }
 @Action(value="uploads")
    public void upload() throws Exception{
            System.out.println("in");
        for (File file: fileUpload) {
            System.out.println("File :" + file);
        }

        for (String fileName: fileUploadFileName) {
            System.out.println("Filename : " + fileName);
        }

        for (String fileContentType: fileUploadContentType) {
            System.out.println("File type : " + fileContentType);
        }

    }

  @Action(value="fileUpload", results = { @Result(name="none",location="/uploadify.jsp")
    })
    public String display() {
        return NONE;
    }
}

我已经尝试更改其给出404的网址,但是使用现在的网址,即上传我正在收到http 302错误

谢谢和问候。

0 个答案:

没有答案