把参数加后面试试。
script : xxx.action?appNo=201312261623request.getParameter("appNo");

解决方案 »

  1.   


    嗯,我知道,但是我先要获取appNo才行啊
      

  2.   


    上传是插件做的,跳转的是servlet后面也不带参数的,我在看插件自己有没有什么参数能够把前台参数带到后台,貌似有个formdata和onUploadStart可以用用
      

  3.   

    后台用什么接收的。
    DiskFileItemFactory factory = new DiskFileItemFactory();
    ServletFileUpload upload = new ServletFileUpload(factory);是这个?
      

  4.   

    你带上试试。 url +参数很正常。
      

  5.   

    <a href="javascript:$('#uploadify').uploadifySettings('scriptData',{'type':$('#TextBox1').val()}); jQuery('#uploadify').uploadifyUpload()">用这个方法吧。本身有这个  uploadifySettings 
      

  6.   

    form里已经加了上传的一个属性,你的提交的格式已经改变了 ,用request.getParameter("appNo");
    是取不到的
      

  7.   

      嗯,对,就是这么做的。我现在试试插件里设置formdata和onUploadStart事件看能不能将appNo传到后台public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setCharacterEncoding("utf-8");

    String savePath = request.getSession().getServletContext().getRealPath(File.separator+"AppImgPackage"+File.separator); DiskFileItemFactory fac = new DiskFileItemFactory();
    ServletFileUpload upload = new ServletFileUpload(fac);
    upload.setHeaderEncoding("utf-8");
    List fileList = null;
    try {
    fileList = upload.parseRequest(request);
    } catch (FileUploadException ex) {
    ex.printStackTrace();
    }
    Iterator<FileItem> it = fileList.iterator();
    String name = "";
    String extName = "";
    String category = "";

    while (it.hasNext()) {
    FileItem item = it.next();

    String appNo = item.getString("appNo");
    System.out.println("第三方应用多图片上传uploadify使用的UploadController中测试appNo:"+appNo);

    if (item.isFormField()) {
    if ("category".equals(item.getFieldName())) {
    category = item.getString("utf-8");
    }
    } else if (!item.isFormField()) {
    name = item.getName();
    System.out.println("第三方应用多图片上传uploadify使用的UploadController中测试name:"+name);
    if (name == null || name.trim().equals("")) {
    continue;
    }
    // 扩展名格式:
    if (name.lastIndexOf(".") >= 0) {
    extName = name.substring(name.lastIndexOf("."));
    }
    savePath = savePath  + category + "/";
    File f1 = new File(savePath);
    if (!f1.exists()) {
    f1.mkdirs();
    }
    File saveFile = new File(savePath + name);
    try {
    item.write(saveFile);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }
    response.getWriter().print(name);
      

  8.   

    if("appNo".equals(item.getFieldName())){
    String appNo= new String(item.getString())
    其中item是遍历出来的项。
    item.getFieldName() 这是去表单里文本框或其他元素的名字。
    item.getString() 取到值 。
    试试吧 
      

  9.   


    我这么弄的
    <p>
    <a href="javascript:$('#uploadify').uploadifySettings('scriptData',{'appNo':$('#appNo').val()})" onClick="javascript:uploadifyUpload()">开始上传</a>&nbsp;
    <a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">取消所有上传</a>
    </p>后台这么取
    String appNo = request.getParameter("appNo");
    System.out.println("第三方应用多图片上传uploadify使用的UploadController中测试appNo:"+appNo);还是没取到呢
      

  10.   


    试了的下面3种方式
    String appNo = item.getFieldName();   //显示  Filename
    String appNo = request.getParameter("appNo");     //显示  null
    String appNo = request.getParameterValues("appNo")[0];    //报错
      

  11.   

    if("appNo".equals(item.getFieldName())){
    String appNo= new String(item.getString())这俩一起用 就取出来了  你好好看 用点心
      

  12.   


    String appNo = "";
    if("appNo".equals(item.getFieldName())){
    appNo = new String (item.getString());
    }
    System.out.println("第三方应用多图片上传uploadify使用的UploadController中测试appNo:"+appNo);依然没有取到呢,哥么
      

  13.   

    我以前写了一个 给你自己看吧 ,我这个当时乱码 ,转换了一下 。public ActionForward insert(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    UserInfo po =new  UserInfo();
    DiskFileItemFactory factory = new DiskFileItemFactory();
    ServletFileUpload upload = new ServletFileUpload(factory);
    // 最大允许大小5M
    // upload.setSizeMax(1024 * 1024 * 5);

    String appName=request.getContextPath(); 
    String path="../webapps"+appName+"/files/";
    String purl="";
    try {
    List<FileItem> items = upload.parseRequest((HttpServletRequest) request);


    for (FileItem item : items) {
    if (!item.isFormField()) {
    String fname = item.getName();
    path=path+fname;
    purl="files/"+fname;
    //System.out.println(path+"$$$"+purl);
    File f=new File(path);
    if(f.getParentFile().exists()) f.getParentFile().mkdirs();
        f.createNewFile();
        FileOutputStream fi=new FileOutputStream(f);
        InputStream in=item.getInputStream();
        byte buffer[] = new byte[8192];
    int bytesRead=0;
    while ( (bytesRead = in.read(buffer, 0, 8192)) != -1){
    fi.write(buffer, 0, bytesRead);
    }
    in.close();
    fi.close();
    }else {
    if("name".equals(item.getFieldName())){

    String name = new String(item.getString()
    .getBytes("ISO-8859-1"),"UTF-8");



    po.setName(name );
    }




    if("city".equals(item.getFieldName()))
    {
    String city = new String(item.getString()
    .getBytes("ISO-8859-1"),"UTF-8");

    po.setCity(city);

    }
    if("number".equals(item.getFieldName())) {
    String s=item.getString();
    po.setNumber(s);
    po.setBirthday(subStr(s));
    };
    if("province".equals(item.getFieldName())) {

    String province = new String(item.getString()
    .getBytes("ISO-8859-1"),"UTF-8");

    po.setProvince(province);
    }

    if("sex".equals(item.getFieldName()))
    {
    String sex = new String(item.getString()
    .getBytes("ISO-8859-1"),"UTF-8");

    po.setSex(sex);
    }



    }
    }
    } catch (Exception e) {
    e.printStackTrace();
    }



    po.setPurl(purl);

    service.insert(po);


    return mapping.findForward("susses");
    }
      

  14.   

     String filedName = item.getFieldName();  
                        if (filedName.equals("appNo")) {  
                       String     appNo= item.getString();  
                        } 
      

  15.   

    function uploadifyUpload(){
    $('#uploadify').uploadifySettings('scriptData', {'appNo' : appNo});
        $('#uploadify').uploadifyUpload();
    }
    </script> <script type="text/javascript">
            $(document).ready(function() {
                $("#uploadify").uploadify({
                    'uploader'       : '<%=request.getContextPath()%>/uploadify.swf',
                    'script'         : '<%=basePath %>/UploadController',
                    'cancelImg'      : '<%=request.getContextPath()%>/images/cancel.png',
                    'queueID'        : 'fileQueue',
                    'auto'           : false,
                    'multi'          : true,
                    'buttonText'     : 'Browse file',
                    'fileExt': '*.jpg;*.gif;*.jpeg;*.png;*.bmp',
                    'fileDesc': '请选择jpg,gif,jpeg,png,bmp格式',
                    'queueSizeLimit' : 5,
                    'method'         : 'GET', 
                                
                onComplete: function (evt, queueID, fileObj, response, data) {
    $('#appImg').val($('#appImg').val()+response+',');
    },
    onError: function(a, b, c, d) {
                alert("文件上传失败");
            }
                });        });页面点击上传处代码
    <p>
    <a href="javascript:$('#uploadify').uploadifySettings('scriptData',{'appNo':$('#appNo').val()})" onClick="javascript:uploadifyUpload()">开始上传</a>&nbsp;
    <a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">取消所有上传</a>
    </p>
      

  16.   


    页面代码放上了,用的Uploadify,刚看了下这篇文章http://www.uploadify.com/forum/#/discussion/5611/uploadifysettings-not-posting-new-script-data/p1
    我尝试加上在uploadify方法中加上
    'scriptData'  : {'weddingId' : '201006-1120140', 'aspectRatio' : '16:9'},
    上传插件就显示异常了
      

  17.   

    Quote: 引用 21 楼 rui888 的回复:

    没取出来,好像插件自带动态取参
      

  18.   

    request.getParameter("appNo");
    你在方法的最上边,用这个取一下试试 。
      

  19.   

    request.getAttibute("appNo"); 试试 。
      

  20.   

     
    我就想不明白,你用 
    String filedName = item.getFieldName();  
    都取到表单的元素名了 
    String     appNo= item.getString();
    这个会取不到值?
    你看看还有其他方法取值。纠结 你帖一下我看你怎么取得 ,
    真纠结
      

  21.   

    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setCharacterEncoding("utf-8");String savePath = request.getSession().getServletContext().getRealPath(File.separator+"AppImgPackage"+File.separator);DiskFileItemFactory fac = new DiskFileItemFactory();
    ServletFileUpload upload = new ServletFileUpload(fac);
    upload.setHeaderEncoding("utf-8");
    List fileList = null;
    try {
    fileList = upload.parseRequest(request);
    } catch (FileUploadException ex) {
    ex.printStackTrace();
    }
    Iterator<FileItem> it = fileList.iterator();
    String name = "";
    String extName = "";
    String category = "";while (it.hasNext()) {
    FileItem item = it.next();String appNo = item.getString("appNo");
    System.out.println("第三方应用多图片上传uploadify使用的UploadController中测试appNo:"+appNo);if (item.isFormField()) { String filedName = item.getFieldName();  
                        if (filedName.equals("appNo")) {  
                       String     appNo= item.getString();  
       System.out.print(appNo);
                        }
     if ("category".equals(item.getFieldName())) {
    category = item.getString("utf-8");
    }
    } else if (!item.isFormField()) {
    name = item.getName();
    System.out.println("第三方应用多图片上传uploadify使用的UploadController中测试name:"+name);
    if (name == null || name.trim().equals("")) {
    continue;
    }
    // 扩展名格式:
    if (name.lastIndexOf(".") >= 0) {
    extName = name.substring(name.lastIndexOf("."));
    }
    savePath = savePath  + category + "/";
    File f1 = new File(savePath);
    if (!f1.exists()) {
    f1.mkdirs();
    }
    File saveFile = new File(savePath + name);
    try {
    item.write(saveFile);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }
    response.getWriter().print(name);
      

  22.   

    你 firebug 或者 其他工具你监视下,你的值有没有传递。 
      

  23.   

    url 后面加参数应该可以用req 取到呀!!!
    form 里的 method="POST" enctype="multipart/form-data"  加了以后
    表单提交 后台req是取不到的
      

  24.   

    点击开始上传只是纯粹的上传图片,页面下面还有个提交按钮的,点击提交才把其他的数据保存,怎么说到Url了呢?不是很理解
      

  25.   

    好桑心,都没玩过uploadify,自己查询多日的资料,使用format和 onstart...这两个方法将值传到前台,前台如何接受值这块没整好,难道就要这么结贴了。。