日期:2014-05-19  浏览次数:20664 次

<s:select> 标签问题
页面的代码如下:


HTML code
<s:action namespace="/competitions" name="listcompetitions" id="bean" />     
                                                         
                    <s:select list="bean.listcompetitions" name="selectCompetitions" id="selectCompetitions" listKey="id" listValue="name"
                        headerKey="" headerValue="--请选择赛事--" theme="simple">
                    </s:select>



Struts2中list的配置如下:

XML code


<action name="listcompetitions" class="competitionsAction"
            method="listCompetitions">
            <result name="success">/web/competitions/competitionsList.jsp</result>
            <result name="input">/web/competitions/error.jsp</result>
        </action>



Action中

private List<Competitions> listCompetitions;

get、set方法都有,并且listCompetitions 方法能正确调用,并且有值!

后台执行的代码以及错误如下:
Java code


2012-4-11 22:06:39 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'selectCompetitions': The requested list key 'bean.listcompetitions' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
    at org.apache.struts2.components.Component.fieldError(Component.java:237)
    at org.apache.struts2.components.Component.findValue(Component.java:358)
    at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
    at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
    at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:856)
    at org.apache.struts2.components.UIBean.end(UIBean.java:510)
    at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
    at org.apache.jsp.web.unitInfo.unitInfoAdd_jsp._jspx_meth_s_005fselect_005f0(unitInfoAdd_jsp.java:730)
    at org.apache.jsp.web.unitInfo.unitInfoAdd_jsp._jspService(unitInfoAdd_jsp.java:493)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.Appl