-->

在形式上使用POST方法时,遇到了错误(Getting error when using post

2019-08-01 21:10发布

我当我使用POST方法,同时传递形式下页这个问题的重复获得空链接文本

<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方法。

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

</body>
</html>

这是关系到幂等财产的任何方式? 我很困惑,为什么我不能在testjsp页面访问变量PRIO。

Answer 1:

您的编码作为你的请求multipart/form-data ,经常被用来上传文件。 servlet容器不包含支撑于自动解码该数据,仅application/x-www-form-urlencoded数据(缺省值)。 要使用multipart/form-data ,你需要一个第三方的MIME解析器像Apache的通用FileUpload 。



文章来源: Getting error when using post method in form