jsp传参,后台接收为null
我的表单:<bodyonload="load()"><formid="formStep"action="ruleDefine.do?actionType=queryByC...
我的表单:<body onload="load()">
<form id="formStep" action="ruleDefine.do?actionType=queryByConditions&pageIndex=${pageIndex }" method="post" >
<input type="hidden" name="ruleName" value="${ruleName }"/>
<input type="hidden" name="key" value="${key }"/>
<input type="hidden" name="creater" value="${creater }"/>
<input type="hidden" name="validStatus" value="${validStatus }"/>
</form>
</body>
<script type="text/javascript">
function load(){
document.getElementById("formStep").submit();
}
</script>
/*获取参数*/
String pageIndex=request.getParameter("pageNo");
String ruleName=request.getParameter("ruleName");
System.out.println(pageIndex+"参数");
String validStatus=request.getParameter("validStatus");
String key=request.getParameter("key");
String creater=request.getParameter("creater");
UIW_Rule_DefineAction wRuleDefineAction = new UIW_Rule_DefineAction();
wRuleDefineAction.deleteById(request, response);
W_rule_defineDto wRuleDefineDto = new W_rule_defineDto();
wRuleDefineDto.setValidStatus("*");
request.setAttribute("wRuleDefineDto", wRuleDefineDto);
request.setAttribute("pageIndex", pageIndex);
request.setAttribute("ruleName", ruleName);
request.setAttribute("validStatus", validStatus);
request.setAttribute("key", key);
request.setAttribute("creater", creater);
主jsp中:
举一个
创建人:
</td>
<td height="27" class="value_text" align="left">
<input class="input_input" type="text" name="creater"
value="${w_rule_defineDto.creater}" />
</td>
web.xml中
<forward name="queryByConditions" path="/jsp/messageManager/replayPolicyManager/showRuleDefine.jsp"/>
<forward name="insert" path="/ruleDefine.do?actionType=queryByConditions" redirect="true" />
<forward name="deleteById" path="/jsp/messageManager/replayPolicyManager/showRuleDefineOK.jsp" />
我在后台取得的参数为null
是不是页面就没有获得参数,所以后台就更不可能有参数了,是这个意思么?
求大虾助我一臂之力,帮忙解决一下这是什么问题 展开
<form id="formStep" action="ruleDefine.do?actionType=queryByConditions&pageIndex=${pageIndex }" method="post" >
<input type="hidden" name="ruleName" value="${ruleName }"/>
<input type="hidden" name="key" value="${key }"/>
<input type="hidden" name="creater" value="${creater }"/>
<input type="hidden" name="validStatus" value="${validStatus }"/>
</form>
</body>
<script type="text/javascript">
function load(){
document.getElementById("formStep").submit();
}
</script>
/*获取参数*/
String pageIndex=request.getParameter("pageNo");
String ruleName=request.getParameter("ruleName");
System.out.println(pageIndex+"参数");
String validStatus=request.getParameter("validStatus");
String key=request.getParameter("key");
String creater=request.getParameter("creater");
UIW_Rule_DefineAction wRuleDefineAction = new UIW_Rule_DefineAction();
wRuleDefineAction.deleteById(request, response);
W_rule_defineDto wRuleDefineDto = new W_rule_defineDto();
wRuleDefineDto.setValidStatus("*");
request.setAttribute("wRuleDefineDto", wRuleDefineDto);
request.setAttribute("pageIndex", pageIndex);
request.setAttribute("ruleName", ruleName);
request.setAttribute("validStatus", validStatus);
request.setAttribute("key", key);
request.setAttribute("creater", creater);
主jsp中:
举一个
创建人:
</td>
<td height="27" class="value_text" align="left">
<input class="input_input" type="text" name="creater"
value="${w_rule_defineDto.creater}" />
</td>
web.xml中
<forward name="queryByConditions" path="/jsp/messageManager/replayPolicyManager/showRuleDefine.jsp"/>
<forward name="insert" path="/ruleDefine.do?actionType=queryByConditions" redirect="true" />
<forward name="deleteById" path="/jsp/messageManager/replayPolicyManager/showRuleDefineOK.jsp" />
我在后台取得的参数为null
是不是页面就没有获得参数,所以后台就更不可能有参数了,是这个意思么?
求大虾助我一臂之力,帮忙解决一下这是什么问题 展开
展开全部
简单看了一下你的代码,是不是你打印的那个参数为null,即pageIndex为null?
如果是的话,问题可能出在页面,我在你的jsp代码中没有找到name=pageNo的表单项,那么你在获取时:String pageIndex=request.getParameter("pageNo"); pageNo自然就取不到了,则pageIndex就是null了。
如果是的话,问题可能出在页面,我在你的jsp代码中没有找到name=pageNo的表单项,那么你在获取时:String pageIndex=request.getParameter("pageNo"); pageNo自然就取不到了,则pageIndex就是null了。
更多追问追答
追问
对的,我打印pageIndex为null,但是其余的几个参数也是为null,我认为是页面就没有获得参数,一直为空,所以action里就取不到,可是怎么解决呢 就算pageno为空,那几个参数呢?我打印了也没传过来,我用什么方法可以让页面接收这些参数呢?只有页面接收到才能走后台啊,
追答
我建议你可以把页面的数据写几个固定值,看看后台能不能拿到
比如:
<input type="hidden" name="ruleName" value="ruleName123"/>
<input type="hidden" name="key" value="key123"/>
<input type="hidden" name="creater" value="creater123"/>
<input type="hidden" name="validStatus" value="validStatus123"/>
如果后台拿到了,那就说明是你页面的问题。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询