如何使用Servlet获取值<select>?</select>

时间:2013-09-25 21:01:17

标签: javascript jquery forms servlets

当我使用request.getParameter(“itemSelect”)时,它返回“null”,因为enctype =“multipart / form-data”。如果我删除了这个属性,我可以使用HTML和Servlet来获取没有JQuery的值,这样<form id="formupload" action="MyServlet" method="POST">。如何使用Servlet获取此表单的值?

我的HTML表单:

<form id="formupload" method="POST" enctype="multipart/form-data">
    <select id="itemSelected" name="itemSelected">
    </select>
    <span id="btnfile" class="btn btn-success fileinput-button">
        <i class="icon-plus icon-white"></i>
        <span>Selecionar Arquivo...</span>
        <input id="file" type="file" name="files">
    </span>

    <button id="upload" type="submit" class="btn btn-primary" title="Adicione um arquivo para habilitar o botão.">
        <i class="icon-upload icon-white"></i>
        <span>Iniciar upload</span>
    </button>
</form>

JQuery功能:

$('form').ajaxForm({
    url: 'url',
    beforeSend: function() {
        // $('#progress').append('<div class="progress"><div class="bar"></div ><div class="percent">0%</div></div>');
        message.empty();
        var percentVal = '0%';
        bar.width(percentVal);
        percent.html(percentVal);
    },
    uploadProgress: function(event, position, total, percentComplete) {
        var percentVal = percentComplete + '%';
        bar.width(percentVal);
        percent.html(percentVal);
    },
    success: function() {
        var percentVal = '100%';
        bar.width(percentVal);
        percent.html(percentVal);
        $('table td#start0').append('<img src="img/success.png">');
    },
    error: function() {
        $('table td#start0').append('<img src="img/error.png">');
    },
    complete: function(xhr) {
        message.html(xhr.responseText);
    }
});
}

0 个答案:

没有答案