在表单中使用post方法时出错 [英] Getting error when using post method in form

查看:162
本文介绍了在表单中使用post方法时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用post方法将表单传递到下一页时,我得到空值
这个问题的重复
链接文字

I am getting null when I am using post method while passing a form to the next page A repeat of this question link text

<html>
<head>
Title
<script>
function callme()
{        
alert("Hi");         
alert(document.getElementById("prio").value);       
}
</script>   
</head>
<body>
<FORM method="post" name="test"enctype="multipart/form-data" action="testjsp.jsp" >
<select name="prio" id="prio"> 
<option>1</option>
<option>2</option>
</select>
<input type="submit" value="Submit" onClick=callme();>
</form>
</body>
</html>

在testjsp.jsp我试图打印prio变量,我无法做到及其prining null.I只想访问其他服务器端组件中的变量prio,并且还想使用post方法。

IN testjsp.jsp I am trying to prin the prio variable which I am not able to do and its prining null.I just want to access the variable prio in some other server side component and also want to use post method.

<html>
<head>
Title  
</head>
<body>
<%
String prio=request.getParameter("prio");
out.println("the value of prio is"+prio);
%>

</body>
</html>

这与幂等属性有关吗?
我很困惑为什么我无法访问testjsp页面中的变量prio。

Is this any way related to Idempotent property? I am confused why I could not access the variable prio in the testjsp page.

推荐答案

您正在编码您的请求如 multipart / form-data ,通常用于上传文件。该servlet容器不包括支持自动解码这些数据,只有 application / x-www-form-urlencoded 数据(默认值)。要使用 multipart / form-data ,您需要第三方MIME解析器,如 Apache commons fileUpload

You are encoding your request as multipart/form-data, often used to upload files. The servlet container does not include support to automatically decode this data, only application/x-www-form-urlencoded data (the default). To use multipart/form-data you need a 3rd party MIME parser like Apache commons fileUpload.

这篇关于在表单中使用post方法时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆