【问题标题】:How to get Parameters of web Page with multipart, using commons.fileupload如何使用 commons.fileupload 获取多部分网页的参数
【发布时间】:2013-09-28 09:38:37
【问题描述】:

谁能帮我使用加密类型多部分访问request.getParameter()。或者请告诉我是否有任何其他方式获取网页的参数,多部分

【问题讨论】:

    标签: jsp servlets apache-commons


    【解决方案1】:

    您可以像平常一样获取参数。我的意思是,在 doPost() 方法中,您在请求对象上调用 getParameter("paramtername")。

    例如:

    如果您要上传的表单如下:

    <form action="${pageContext.request.contextPath}/servletupload" method="POST" enctype="multipart/form-data">
        <input type="hidden" value="testvalue" name ="parametername"/>
        Select file: <input type="file" name="file" size="60"/>
        <input type="submit" value="upload"/>
    </form>
    

    您的 doPost() 方法如下:

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    
        String parametername = request.getParameter("parametername");
    
        // upload code here
    
    }
    

    【讨论】:

    • 这就是我要问的。我无法正常使用 enc-type 作为 multipart 获取参数。我得到空值。参数名称:null 操作:null 数据库名称:null 这是结果。
    猜你喜欢
    • 2011-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多