在表单中使用post方法时出错

时间:2009-08-20 10:45:11

标签: html jsp struts html-select idempotent

当我在将表单传递到下一页时使用post方法时,我得到null 重复这个问题 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。我只想在其他服务器端组件中访问变量prio并且还想使用post方法。 / p>

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

</body>
</html>

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

1 个答案:

答案 0 :(得分:1)

您将请求编码为multipart/form-data,通常用于上传文件。 servlet容器不支持自动解码此数据,仅支持application/x-www-form-urlencoded数据(默认值)。要使用multipart/form-data,您需要第三方MIME解析器,例如Apache commons fileUpload