request.getParameter的问题 为什么取不到

rex0y 2002-11-27 01:35:43
1 HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>发送邮件</title>
<script language="javascript">
function addattach(){
form1.action="test.jsp";
alert(form1.opflag.value);
form1.submit();
}
//-->
</script>
</head>
<body>
<form name="form1" method="post" action="" enctype="text/plain">
<table width="70%" border="1">
<tr>
<td><font size="1"> </font></td>
<td colspan="2"><font size="1">
<input name="addAttach" type="button" id="addAttach" onClick="addattach()" value="添加" />
</font></td>
</tr>
</tr>
</table>
</form>
</body>
</html>
2 JSP
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%
String str=request.getParameter("opflag");
out.println(str+"234324");
%>
3 RESULT
结果是 null234324

我以前也用过request.getParameter好多次啊 why why
...全文
98 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
nbm0 2002-11-27
  • 打赏
  • 举报
回复
好厉害,这也知道!
rong_xing 2002-11-27
  • 打赏
  • 举报
回复
rex0y 2002-11-27
  • 打赏
  • 举报
回复
好像只有不写enctype 才能用request.getParameter,指定enctype的得自己解析request 对象吧
是这样么?
rong_xing 2002-11-27
  • 打赏
  • 举报
回复
request封装参数的时候格式不一样了

如果你把request用流读出来,按照协议解包,还是能读出来的
但是直接调用req.getParameter就不行了

rex0y 2002-11-27
  • 打赏
  • 举报
回复
去掉enctype 行了,rong_xing 大哥,给个理由吧
rong_xing 2002-11-27
  • 打赏
  • 举报
回复
把enctype去掉试试

rex0y 2002-11-27
  • 打赏
  • 举报
回复
没写全 opflag 是个隐藏域
<form name="form1" method="post" action="" enctype="text/plain">
<table width="70%" border="1">
<tr>
<td nowrap="nowrap"><font size="1"><input name="opflag" type="hidden" value="add" /></font></td>
<td colspan="2"><font size="1">
<input name="to" type="text" id="to" />
</font></td>
</tr>
sunni 2002-11-27
  • 打赏
  • 举报
回复
<input name="opflag" type="button" id="addAttach" >
caoze 2002-11-27
  • 打赏
  • 举报
回复
可千万别晕。
qxjavajava 2002-11-27
  • 打赏
  • 举报
回复
hehe .你的什么叫opflag 呀

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧