Html:select和Html:选项问题

时间:2011-09-07 12:05:28

标签: struts struts-1

我在下面有例外,我提到了有关此错误的所有页面。

    org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/dublicateId.jsp at line 46

    43:                       
    44:                          <tr><td>Reason For Requesting Dublicate ID:</td>
    45:                        <td>
    46:                            <html:select  property="reason" size="2" >
    47:                                <html:options name="lost"/>
    48:                                <html:options name="damaged"/>
    49:                   </html:select> 


    Stacktrace:
        org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


    root cause 

    javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
        org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
        org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
        org.apache.jsp.jsp.dublicateId_jsp._jspService(dublicateId_jsp.java:174)
        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:393)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


    root cause 

    javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
        org.apache.struts.taglib.html.SelectTag.calculateMatchValues(SelectTag.java:240)
        org.apache.struts.taglib.html.SelectTag.doStartTag(SelectTag.java:200)
        org.apache.jsp.jsp.dublicateId_jsp._jspx_meth_html_005fselect_005f0(dublicateId_jsp.java:212)
        org.apache.jsp.jsp.dublicateId_jsp._jspService(dublicateId_jsp.java:121)
        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:393)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.

我的jsp页面:

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ page import="com.rec.bookbank.persitencejavafile.DuplicateIdObject" %>
<%@ page import="java.util.*;"%>

<html>
      <body>
          <html:form  action="/id" ></html:form>
            <div id="container">
                <div id="header">
                    <table width="960">
                          <tr>
                            <td id="header1"  align="center">
                                DUBLICATE ID CARD REQUEST 
                            </td><td><a href="/REC_BookBank/jsp/exisitingUser.jsp">Back</a></td>
                        </tr>
                    </table>    
                </div>

                <div id="content">
                <table cellpadding="10" align="center">
                         <tr><td>Reason For Requesting Dublicate ID:</td>
                       <td>
                           <html:select  property="reason" size="2" >
                               <html:options name="lost"/>
                               <html:options name="damaged"/>
                  </html:select> 
          </td></tr>
            <tr><td>Mode of Dispatch ID card :</td>
                       <td>
                           <html:select  property="dispatch" size="2" >
                               <html:options name="courier"/>
                               <html:options name="manual"/>
                  </html:select> 
          </td></tr>
                   <tr>
                          <td>
                               Conformation Of Mailing Address:      
                          </td>
                          <td>

                          </td>
                        </tr>
                        <tr>
                            <td><font size="3"id="header1">Charges Applicable</font></td>
                        </tr>
                        <tr><td>Components  </td><td>Amount IN INR</td></tr>
                        <tr><td>Dublicate Card Charges</td><td><html:text property="cardcharges" value=""/></td>
                        </tr>
                        <tr>
                            <td>Courier Charges                   
                            </td><td>
                       </td>
                        </tr>
                        <tr>
                            <td>Grant Total</td><td>></td>  
                        </tr>
                        <tr><td><html:submit property="submit" value="paynow" /></td><td><html:button property="" value="Later"/></td></tr>
                    </table>
                </div>
            </div>
    </body>
</html>

我的操作页面:

package com.rec.bookbank.action;

import com.rec.bookbank.form.DuplicateIdForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import com.rec.bookbank.Constants.Constants;
import com.rec.bookbank.persitencejavafile.DuplicateIdObject;
import com.rec.bookbank.dao.DuplicateIdDAO;
import java.util.List;
import java.util.ArrayList;

public class DuplicateIdAction extends org.apache.struts.action.Action {
        public ActionForward execute(ActionMapping mapping, ActionForm  form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        DuplicateIdForm duplicateIdForm=(DuplicateIdForm)form;
        List<DuplicateIdObject> convert=new ArrayList<DuplicateIdObject>();
        convert=DuplicateIdDAO.duplicateidrequest();
        System.out.println("list in action::" +convert.size());
        request.setAttribute("reason", convert);
        System.out.print("request in Action::"+request.getAttribute("duplicate"));
        return mapping.findForward(Constants.ACTION_FORWARD_SUCCESS);
  }
}

我的道:

package com.rec.bookbank.dao;
import com.rec.bookbank.form.DuplicateIdForm;
import com.rec.bookbank.sessionCfg.HibernateUtil;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Query;
import com.rec.bookbank.persitencejavafile.DuplicateIdObject;

public class DuplicateIdDAO {

    public static  List duplicateidrequest() {
        Session session=null;
           try {
            List  duplicate = new ArrayList();

            session = HibernateUtil.getSession();
            System.out.println(" Session :: "+session);
            Query query = session.createSQLQuery("{call SP_Duplicate()}");
            duplicate  = getList(query.list());
            System.out.println("in dao getduplicate----"+duplicate);
            if(duplicate!=null)
            return duplicate;
            else
                return new ArrayList();
           } catch(Exception e) {
               System.out.println("Exception in duplicateidrequest::"+e);
               return  null;
           }
           finally {
               session.close();
           }          
          }     

    public static  List<DuplicateIdObject> getList ( List<Object[]>duplicate ) {
    System.out.println("in convertor");
    List<DuplicateIdObject>duplicateobjectlist = new ArrayList<DuplicateIdObject>();
    for(Object[] array:duplicate) {
        System.out.println("value in method::"+duplicate.size());
        DuplicateIdObject duplicateIdObject=new DuplicateIdObject();
               duplicateIdObject.setReason(array[0].toString());
               duplicateIdObject.setDispatch(array[1].toString());
               duplicateobjectlist.add(duplicateIdObject);
    }
    return duplicateobjectlist;
    }
} 

我的持久性课程:

package com.rec.bookbank.persitencejavafile;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;

@Entity
public class DuplicateIdObject implements Serializable
{
    @Id
private int id;
private String reason;
private String dispatch;
private String address;
private String cardcharges;
private String couriercharges;
private String total;

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCardcharges() {
        return cardcharges;
    }

    public void setCardcharges(String cardcharges) {
        this.cardcharges = cardcharges;
    }

    public String getCouriercharges() {
        return couriercharges;
    }

    public void setCouriercharges(String couriercharges) {
        this.couriercharges = couriercharges;
    }

    public String getDispatch() {
        return dispatch;
    }

    public void setDispatch(String dispatch) {
        this.dispatch = dispatch;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getTotal() {
        return total;
    }

    public void setTotal(String total) {
        this.total = total;
    }


}

我的休眠:

package com.rec.bookbank.sessionCfg;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {

    private static final SessionFactory sessionFactory;
    private static final Session session = null;

    static {
        try {
            sessionFactory = new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    public static Session getSession(){
       return sessionFactory.openSession();

    }
}

1 个答案:

答案 0 :(得分:2)

您的表单标签实际上都不在表单中,因为:

<html:form  action="/id" ></html:form>

另外,请注意您的代码格式:IDE会自动执行此操作,它可以帮助您跟踪此类问题。加上它的方式,方式更容易让其他人看到和理解。