是不是必须在每个JSP页面上写如下代码
Vector CLASSA_CODE = new Vector();
CLASSA_CODE.add(new LabelValueBean("d","e"));
pageContext.setAttribute("CLASSA_CODE",CLASSA_CODE);如果这么写了每次进入这个页的时候都要执行他,那么如果在页面上有若干个文本框和若干个下拉列表,第二次再进入这个页的时候文本框的值会被保留,但是下拉列表的值就被还原了,请问怎么做才能不还原.
Vector CLASSA_CODE = new Vector();
CLASSA_CODE.add(new LabelValueBean("d","e"));
pageContext.setAttribute("CLASSA_CODE",CLASSA_CODE);如果这么写了每次进入这个页的时候都要执行他,那么如果在页面上有若干个文本框和若干个下拉列表,第二次再进入这个页的时候文本框的值会被保留,但是下拉列表的值就被还原了,请问怎么做才能不还原.
解决方案 »
- 救命啊,大家帮我看看这个问题,已经很多天了,不知出在哪(JBossManagedConnectionPool] Exception destroying)(Connection timed out)
- 做过lotus notes开发的朋友请进
- 日期格式化的问题从JSP到SERVLET到MYSQL
- 点击个超级连接后提交相应的数据去一个页面处理
- 又是郁闷的乱码问题,搜索了以前的帖子,都没有解决。
- 请教一个选择方式对应时间的问题
- javascript客户端的变量不通过提交如何传到服务器端
- 对标签的理解
- 第一次用Jsp,这是什么错误啊!
- JSP清除session的问题
- 大家都来帮帮我啊!帮的都有分!!在线等急
- &代替&导致的request读不出值的问题
可以用struts的迭代标签去读啊,然后显示在下拉列表里
或者是用EL表达式去迭代
具体用法如下:
<html:select name="testForm" property="select01">
<html:optionsCollection name="testForm" property="testList" value="KEY" label="NAME"/>
</html:select>在<html:select> 中:
name - 表单名称
property - 回调取值变量名称<html:optionsCollection>中:
name="testForm": name - 表单名称
property="testList": property - 一个类型为java.util.List的变量,存储的是下拉列表要显示的值和名称的LIST
value="KEY": value - 下拉列表的value值
label="NAME":label - 下拉列表的label值一般做法:
将下拉列表里的label和value放在hashmap里,然后加到list中,这样利用标签就能自动回显。
然后把这个集合传给view,通过struts的迭代标签显示为下拉列表
然后用request中的setAttribute()方法传到jsp页面上
在页面上接收。最后在循环输出就可以了
HashMap hmp = new HashMap();
hmp.put("labe1", "aa");
hmp.put("labe2", "bb");
hmp.put("labe2", "cc");
List testList = new ArrayList();
testList.add(hmp);
request.setAttribute("testCollection", testList);
return mapping.findForward("success");
页面中的代码是
<html:select name="testCollection" property="param1">
<html:optionsCollection name="testCollection" property="testList" value="value" label="label"/>
</html:select>
错误信息
org.apache.jasper.JasperException: An exception occurred processing JSP page /test2.jsp at line 1310: </head>
11: <body>
12: <html:form action="/test2/sample.do?method=display" method="post">
13: <html:select name="testCollection" property="param1">
14: <html:optionsCollection name="testCollection" property="testList" value="value" label="label"/>
15: </html:select>
16: </html:form>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)请问哪里不对呢