Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何将数据(列表)导入<;选择>;通过struts2框架中的Action类从数据库中标记_Xml_List_Select_Struts2_Action - Fatal编程技术网

Xml 如何将数据(列表)导入<;选择>;通过struts2框架中的Action类从数据库中标记

Xml 如何将数据(列表)导入<;选择>;通过struts2框架中的Action类从数据库中标记,xml,list,select,struts2,action,Xml,List,Select,Struts2,Action,struts2中的标签有问题。我真的不知道这个标签的性能 以前,我的数据库中有一个国家列表,我想把它输入 jsp页面(其中有我的标记): 我需要的是:通过Action类从数据库中获取列表 你能帮我吗?请它正在显示问题,因为在操作类中您的列表没有getter和setter。 在操作中编写getCountry()&setCountry()方法。它肯定会工作得很好。你想从什么样的数据库中获取列表?用action方法填充列表或使用prepare。我做了。但一切都不好。你的action中没有“execut

struts2中的标签有问题。我真的不知道这个标签的性能

以前,我的数据库中有一个国家列表,我想把它输入
jsp页面(其中有我的标记):

我需要的是:通过Action类从数据库中获取列表


你能帮我吗?请

它正在显示问题,因为在操作类中您的列表没有getter和setter。
在操作中编写
getCountry()
&
setCountry()
方法。它肯定会工作得很好。

你想从什么样的数据库中获取列表?用action方法填充列表或使用
prepare
。我做了。但一切都不好。你的action中没有“execute()”方法。您已经在构造函数中编写了代码。我从未用构造函数尝试过它&它在您的代码中也不起作用。因此,编写'execute()'方法并将代码放入其中。对不起,这是真正的代码这是什么意思“对不起,这是真正的代码”?显示您的更新代码以获得进一步帮助。对不起……我弄错了。这是我的新问题。请帮助我
<s:select headerKey="-1" headerValue="Select Search Engines" list="country" name="yoursearch"></s:select>
 public class ShowSelect extends ActionSupport{
    private List<String> country;



    public ShowSelect() {

        country = new ArrayList<String>();
        country.add("google.com");
        country.add("bing.com");
        country.add("yahoo.com");
        country.add("baidu.com");

    }
    public String display() {
        return "success";
    }

    public List<String> getSearchEngine() {
        return country;
    }

    public void setSearchEngine(List<String> country) {
        this.country = country;
    }

}
<action name="search" class="controller.ShowSelect">
   <result name="success">Select.jsp</result>
</action>
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: tag 'select', field 'list': The requested list key '' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)
root cause

tag 'select', field 'list': The requested list key '' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
    org.apache.struts2.components.Component.fieldError(Component.java:237)
    org.apache.struts2.components.Component.findValue(Component.java:358)
    org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
    org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
    org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:856)
    org.apache.struts2.components.UIBean.end(UIBean.java:510)
    org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
    org.apache.jsp.Product.ShowListProduct_jsp._jspx_meth_s_005fselect_005f0(ShowListProduct_jsp.java:253)
    org.apache.jsp.Product.ShowListProduct_jsp._jspx_meth_s_005fdiv_005f0(ShowListProduct_jsp.java:115)
    org.apache.jsp.Product.ShowListProduct_jsp._jspService(ShowListProduct_jsp.java:70)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)