这是我的 Assignemployee.jsp 文件代码
<s:form action="AssignEmployee" name="myForm">
<s:select name="pname" list="projectlist" headerKey="0" label="Select a country" />
<s:submit/>
</s:form>
这是我的 projectlist.java 操作文件
package myPack;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ApplicationAware;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
public class projectlist extends ActionSupport implements ServletRequestAware {
private static final long serialVersionUID = 1L;
HttpServletRequest request;
private List<String> projectlist;
public List<String> getProjectlist() {
return projectlist;
}
public void setProjectlist(List<String> projectlist) {
this.projectlist = projectlist;
}
public void setServletRequest(HttpServletRequest request)
{
this.request = request;
}
public HttpServletRequest getServletRequest(){
return request;
}
public String getDefaultSearchEngine() {
return "yahoo.com";
}
public projectlist()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con=DriverManager.getConnection("jdbc:mysql:///pmt","root","shree");
ps=con.prepareStatement("select * from addproject");
ResultSet res = ps.executeQuery();
while(res.next())
{
projectlist = new ArrayList<String>();
projectlist.add(res.getString("pname"));
}
ps.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public String execute()throws Exception
{
return SUCCESS;
}
public String display() {
return NONE;
}
}
这是struts.xml
<action name="AssignEmployee" class="myPack.projectlist" method="display">
<result name="success">assignemployee.jsp</result>
</action>
当我运行应用程序时,我收到一个错误,例如
严重:servlet [jsp] 的 Servlet.service() 在路径 [/PTMS] 的上下文中抛出异常 [tag 'select', field 'list', name 'pname': 请求的列表键 'projectlist' 无法解析为集合/数组/映射/枚举/迭代器类型。示例:people 或 people.{name} - [unknown location]] 带有根本原因标签“select”、字段“list”、名称“pname”:请求的列表键“projectlist”无法解析为集合/数组/映射/枚举/迭代器类型。示例:人或人。{name} - [未知位置]
如何解决这个错误?