struts2嵌套list属性,接收页面传递过来的参数

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qinzongjian/article/details/84858517

struts2的action里面有个嵌套list的属性List<List<实体类>>  ordprQtyVo;

实体类里面有两个属性:productId,productName

 

jsp页面设置了隐藏域:

<input type="hidden" name="ordprQtyVo[0][0].productId" value="${item.productId}"/>

 

通过这种方式,我们在提交form表单的时候,ordprQtyVo是接收不到任何参数值的,

 

解决方案:

我们新建一个实体类,我这里叫  实体类VO,实体类VO 中就包含一个list属性,如:

private List<实体类> voList;

action类的嵌套list属性改成这样  List<实体类VO>  ordprQtyVo;

然后我们页面的隐藏域改成这样:

<input type="hidden" name="ordprQtyVo[0].voList[0].productId" value="${item.productId}"/>

 

这样的话,form表单提交的时候,action层就能接收到参数值了。

 

展开阅读全文

如何用jsp接收上个页面传递过来参数

01-12

变量初始化总有问题,提示错误见下面;注,我传递的参数较多 ifPublished1-ifPublish29 ;reporttype1....reporttype29;而且有多少参数是动态的由request.getParameter("x")传过来的数决定;哪位给点意见,怎样保存传递过来的参数?rnjsp文件rn<%@ page language="java" %>rn<%@ page contentType="text/html;charset=gb2312" %>rnrn<%rn int n=Integer.parseInt(request.getParameter("x"));rn rn int [n] ifPublished = 1;rn String [n] reporttype=null;rnrn for(int i = 1;irnrnrnrn Untitled Documentrnrnrnrnrnrn<% rn out.println(Integer.parseInt(request.getParameter("x")));rn rn%>rn 恭喜您,更改设置成功!rn<%rn for(int i=1;irnrnrnrnrn执行上面的jsp文件出现错误,如下:rnjavac] Since fork is true, ignoring compiler setting.rn [javac] Compiling 1 source filern [javac] Since fork is true, ignoring compiler setting.rn [javac] E:\WebOA\Tomcat 4.1\work\Standalone\localhost\edoas\edma\edma\report\reportPublished_handle_jsp.java:46: ']' expectedrn [javac] int [n] ifPublished = 1;rn [javac] ^rn [javac] E:\WebOA\Tomcat 4.1\work\Standalone\localhost\edoas\edma\edma\report\reportPublished_handle_jsp.java:46: not a statementrn [javac] int [n] ifPublished = 1;rn [javac] ^rn [javac] E:\WebOA\Tomcat 4.1\work\Standalone\localhost\edoas\edma\edma\report\reportPublished_handle_jsp.java:47: not a statementrn [javac] String [n] reporttype=null;rn [javac] ^rn [javac] E:\WebOA\Tomcat 4.1\work\Standalone\localhost\edoas\edma\edma\report\reportPublished_handle_jsp.java:47: ';' expectedrn [javac] String [n] reporttype=null;rn [javac] ^rn [javac] E:\WebOA\Tomcat 4.1\work\Standalone\localhost\edoas\edma\edma\report\reportPublished_handle_jsp.java:50: cannot resolve symbolrn [javac] symbol : variable ifPublished rn [javac] location: class org.apache.jsp.reportPublished_handle_jsprn [javac] ifPublished[i]=Integer.parseInt(request.getParameter("ifPublished"+i));rn [javac] ^rn [javac] E:\WebOA\Tomcat 4.1\work\Standalone\localhost\edoas\edma\edma\report\reportPublished_handle_jsp.java:51: cannot resolve symbolrn [javac] symbol : variable reporttype rn [javac] location: class org.apache.jsp.reportPublished_handle_jsprn [javac] reporttype[i]=request.getParameter("reporttype"+i);rn [javac] ^rn [javac] E:\WebOA\Tomcat 4.1\work\Standalone\localhost\edoas\edma\edma\report\reportPublished_handle_jsp.java:71: cannot resolve symbolrn [javac] symbol : variable ifPublished rn [javac] location: class org.apache.jsp.reportPublished_handle_jsprn [javac] out.println(ifPublished[i]);rn [javac] ^rn [javac] E:\WebOA\Tomcat 4.1\work\Standalone\localhost\edoas\edma\edma\report\reportPublished_handle_jsp.java:72: cannot resolve symbolrn [javac] symbol : variable reporttype rn [javac] location: class org.apache.jsp.reportPublished_handle_jsprn [javac] out.println(reporttype[i]);rn 论坛

没有更多推荐了,返回首页