日期:2014-05-18  浏览次数:20674 次

logic遍历的问题
Java code

DBSource ds = new DBSource();
if (url.equals("/command/currency.jsp")) {
    List<Currencyiso> CurrList = ds.DBSourceforCurrencyiso();
    request.setAttribute("CurrList", CurrList);
    System.out.println("执行/command/currency.jsp");
}


在访问页面时就触发上面的语句向request中添加一个被泛型的list数组
Currencyiso是由spring生成的bean

Java code

<logic:iterate id="CurrList" name="CurrList" scope="request">
<option value='<bean:write name="CurrList" property="alphacode"/>' ><bean:write name="CurrList" property="alphacode"/></option>
</logic:iterate>


在页面中我用logic遍历
alphacode在Currencyiso有set/get方法
xml中名称也是对应的

但是我访问页面就出现如下错误:
执行/command/currency.jsp
2008-11-13 17:54:12 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: No getter method for property: "alphacode" of bean: "CurrList"
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:915)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:233)
at org.apache.jsp.command.currency_jsp._jspx_meth_bean_005fwrite_005f0(currency_jsp.java:515)
at org.apache.jsp.command.currency_jsp._jspService(currency_jsp.java:199)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.by.bill.filter.RequestFilter.doFilter(RequestFilter.java:92)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)



望高手指点!!
不胜感激

------解决方案--------------------
你的这个问题和我遇到的差不多,根据我的经验你应该把这个list定义到bean里面去,然后这样写
<logic:iterate id="CurrList" property="CurrList" name="bean的名字" scope="request">
具体的你看看我的blog
http://