当前位置:编程学习 > JAVA >>

着急!Failed to obtain the specified collection:

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: 指定されたコレクションの取得に失敗しました
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


原因 

javax.servlet.ServletException: javax.servlet.jsp.JspException: 指定されたコレクションの取得に失敗しました
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.left.addDate_jsp._jspService(addDate_jsp.java:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


原因 

javax.servlet.jsp.JspException: 指定されたコレクションの取得に失敗しました
org.apache.struts.taglib.html.OptionsCollectionTag.doStartTag(OptionsCollectionTag.java:181)
org.apache.jsp.left.addDate_jsp._jspx_meth_html_005foptionsCollection_005f0(addDate_jsp.java:610)
org.apache.jsp.left.addDate_jsp._jspx_meth_html_005fselect_005f1(addDate_jsp.java:541)
org.apache.jsp.left.addDate_jsp._jspx_meth_html_005fform_005f0(addDate_jsp.java:317)
org.apache.jsp.left.addDate_jsp._jspx_meth_html_005fhtml_005f0(addDate_jsp.java:212)
org.apache.jsp.left.addDate_jsp._jspService(addDate_jsp.java:94)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

jsp code:
<html:select property="dutyid">
<html:option value="0">请选择职位</html:option>
<html:optionsCollection property="dutys" value="hd_n_id" label="ndi_v_name" />
</html:select> --------------------编程问答-------------------- 翻译过来报的错是:   Failed to obtain the specified collection

《----------------------------jsp code---------------------------->
jsp code:
<html:select property="dutyid">
<html:option value="0">请选择职位</html:option>
<html:optionsCollection property="dutys" value="hd_n_id" label="ndi_v_name" />
</html:select> 


其中“dutys”为Duty bean的集合

《----------------------------------------Duty  bean-----------------------------》

Duty bean:

package com.modified.model;

public class Duty {
private int hdi_n_id;
private String hdi_v_name;
public void setHdi_n_id(int hdi_n_id) {
this.hdi_n_id = hdi_n_id;
}
public int getHdi_n_id() {
return hdi_n_id;
}

public void setHdi_v_name(String hdi_v_name) {
this.hdi_v_name = hdi_v_name;
}
public String getHdi_v_name() {
return hdi_v_name;
}
}

《------------------------------actionform-------------------------------》
actionfrom:


package com.modified.form;

import org.apache.struts.action.*;
import javax.servlet.http.HttpServletRequest;
import com.modified.model.Duty;

import com.modified.model.Branch;
public class Newbranch extends ActionForm{

/**
 * 
 */
private static final long serialVersionUID = 1L;
private String branchname;
private String branchdesc;
private String dutyid;
private String branchid;
private String name;
private String cells;
    private Branch branchs[];



private Duty dutys[];

public void setdutys(Duty[] dutys) {
this.dutys = dutys;
}
public Duty[] getdutys() {
return dutys;
}


public void setPbranchname(String name) {
this.name = name;
System.out.println(name);
}
public String getPbranchname() {
return name;
}
public void setDutyid(String dutyid) {
this.dutyid = dutyid;
}
public String getDutyid() {
return dutyid;
}
public void setBranchdesc(String branchdesc) {
this.branchdesc = branchdesc;
}
public String getBranchdesc() {
return branchdesc;
}
public void setBranchname(String branchname) {
this.branchname = branchname;
}
public String getBranchname() {
return branchname;
}
public void setCells(String cells) {
this.cells = cells;
}
public String getCells() {
return cells;
}
public void setBranchid(String branchid) {
this.branchid = branchid;
}
public String getBranchid() {
return branchid;
}
public void setBranchs(Branch branchs[]) {
this.branchs = branchs;
}
public Branch[] getBranchs() {
return branchs;
}

public ActionErrors validate(ActionMapping mapping,HttpServletRequest request){
ActionErrors errors =new ActionErrors();
if(branchname==null||branchname.length()<1){
errors.add("name", new ActionMessage("部门名不能为空"));
}

if(branchid=="-1"||branchid==null){
errors.add("id",new ActionMessage("请选择所属部门")); }
return errors;
}
}

<----------------------------dao------------------------------->


@SuppressWarnings({ "finally", "static-access" })
public Duty[] selects(){
try {
conn = jdbc.getMySqlConnection();
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("conn success");
String sql = "select * from hr_duty_info where hdi_c_state='1'";
int i=0;
ResultSet rs = null;
try{
this.getConn();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()){
dutys[i].setHdi_n_id(rs.getInt("hdi_n_id"));
dutys[i].setHdi_v_name(rs.getString("hdi_v_name"));
i++;
} try {
rs.close();
pstmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return dutys;
}catch(SQLException e){
e.printStackTrace();
}finally {
try {
rs.close();
pstmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();

}

return dutys;
}
}



<----------------------------action------------------------->

public class BranchAction extends Action{

private Duty dutys[];
private Branch branchs[] = null;
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
ActionErrors errors =form.validate(mapping,request);
if(!errors.isEmpty()){
System.out.println("errors.isEmpty");
saveErrors(request,errors);
return mapping.findForward("false");
}
HttpSession session=request.getSession();
String userid=(String)session.getAttribute("heb_n_id");
Newbranch branch =(Newbranch)form;
String branchname=branch.getBranchname();//获得新增部门名
String branchdesc=branch.getBranchdesc(); //获得部门描述
String pbranchname=branch.getPbranchname();//获得所属部门
String pbranchid=branch.getBranchid();//获得所属部门ID
String cells=branch.getCells();
Addbranc dao=new Addbranc();
String spase = "      ";

//获得职位下拉列表
dutys=dao.selects();
branch.setdutys(dutys);


帮忙看下吧,谢谢啦
补充:Java ,  Java EE
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,