找不到名称下的bean

问题描述 投票:0回答:1

我现在正在使用 JSP,但我在使用 Bean 时遇到了一些问题。

我有这样的消息:

javax.servlet.jsp.JspException: Cannot find bean under name segments

Struts 配置:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config SYSTEM
"dtds/struts-config_1_3.dtd">
<struts-config>
    <form-beans>
        <form-bean
            name="loginForm"
            type="com.un23.security.filters.LoginForm"/>
        <form-bean name="codeForm" type="com.alodiga.sisac.plans.action.code.CodeForm"/>
        <form-bean name="costListForm" type="com.alodiga.sisac.plans.action.costList.CostListForm" />
        <form-bean name="didRentForm" type="com.alodiga.sisac.plans.action.didRent.DidRentForm"/>
        <form-bean name="discountForm" type="com.alodiga.sisac.plans.action.discount.DiscountForm"/>
        <form-bean name="dnForm" type="com.alodiga.sisac.plans.action.dn.DnForm"/>
        <form-bean name="favoriteCountryForm" type="com.alodiga.sisac.plans.action.favoriteCountry.FavoriteCountryForm"/>
        <form-bean name="importCostListForm" type="com.alodiga.sisac.plans.action.costList.ImportCostListForm" />
        <form-bean name="importDidForm" type="com.sg123.actions.did.ImportDidForm"/>
        <form-bean name="importDidRentForm" type="com.alodiga.sisac.plans.action.didRent.ImportDidRentForm"/>
        <form-bean name="importDnForm" type="com.alodiga.sisac.plans.action.dn.ImportDnForm"/>
        <form-bean name="importEquipmentInstanceForm" type="com.sg123.actions.equipmentInstance.ImportEquipmentInstanceForm"/>
        <form-bean name="importFavoriteCountryForm" type="com.alodiga.sisac.plans.action.favoriteCountry.ImportFavoriteCountryForm"/>
        <form-bean name="importTerminationPriceListForm" type="com.alodiga.sisac.plans.action.terminationPriceList.ImportTerminationPriceListForm" />
        <form-bean name="importOriginationPriceListForm" type="com.alodiga.sisac.plans.action.originationPriceList.ImportOriginationPriceListForm" />
        <form-bean name="originationPriceListForm" type="com.alodiga.sisac.plans.action.originationPriceList.OriginationPriceListForm" />
        <form-bean name="planForm" type="com.alodiga.sisac.plans.action.plan.PlanForm" />
        
        <form-bean name="priceListId" type="com.alodiga.sisac.plans.action.originationPriceListAction.priceListId" />
        
        <form-bean name="promotionForm" type="com.alodiga.sisac.plans.action.promotion.PromotionForm"/>
        <form-bean name="terminationPriceListForm"  type="com.alodiga.sisac.plans.action.terminationPriceList.TerminationPriceListForm" />
        <form-bean name="terminationPriceForm"  type="com.alodiga.sisac.plans.action.terminationPriceList.TerminationPriceForm" />
        <form-bean name="scheduleForm" type="com.alodiga.sisac.plans.action.schedule.ScheduleForm"/>
        <form-bean name="serviceEquipmentModelForm" type="com.alodiga.sisac.plans.action.serviceEquipmentModel.ServiceEquipmentModelForm"/>
        <form-bean name="serviceRentForm" type="com.alodiga.sisac.plans.action.serviceRent.ServiceRentForm"/>
    
        <form-bean name="enterprises" type="com.alodiga.sisac.plans.action.didRent.ListDidRent"/>

        
    </form-beans>

    <global-exceptions>
    </global-exceptions>

    <global-forwards>
        <forward name="welcome"  path="/Welcome.do"/>
<!--         Linea agregada por el enterprises -->
        <forward name="enterprises" path="/ListDidRent.do"/>
    </global-forwards>
    
    
    <action-mappings>
         <action
            path="/Login"
            type="com.un23.security.filters.Authenticator" 
            name="loginForm"
            validate="true"
            input="/login.jsp"
            >
            <forward name="success"
                path="/welcome.jsp" />
            <forward name="error"
                path="/WEB-INF/pages/general/generalError.jsp" />
        </action>
        <action path="/Welcome" forward="/welcome.jsp"/>
        <action path="/*/List*" type="com.alodiga.sisac.plans.action.{1}.List{2}Action" name="{1}Form" scope="request" input="/WEB-INF/pages/{1}/list{2}.jsp">
            <forward name="success" path="/WEB-INF/pages/{1}/list{2}.jsp" />
            <forward name="error" path="/WEB-INF/pages/general/generalError.jsp" />
        </action>
        <action path="/*/Add*" type="com.alodiga.sisac.plans.action.{1}.Add{2}Action">
            <forward name="success" path="/WEB-INF/pages/{1}/add{2}.jsp" />
            <forward name="error" path="/WEB-INF/pages/general/generalError.jsp" />
        </action>
        <action path="/*/View*" type="com.alodiga.sisac.plans.action.{1}.View{2}Action">
            <forward name="success" path="/WEB-INF/pages/{1}/view{2}.jsp" />
            <forward name="error" path="/WEB-INF/pages/general/generalError.jsp" />
        </action>
        <action path="/*/Export*" type="com.alodiga.sisac.plans.action.{1}.Export{2}Action" name="listForm" scope="request" input="/WEB-INF/pages/{1}/export{2}.jsp">
            <forward name="success" path="/{1}/List{2}.do" />
            <forward name="error" path="/{1}/List{2}.do" />
        </action>
        <action path="/*/Import*" type="com.alodiga.sisac.plans.action.{1}.Import{2}Action">
            <forward name="success" path="/WEB-INF/pages/{1}/import{2}.jsp" />
            <forward name="error" path="/WEB-INF/pages/{1}/import{2}.jsp" />
        </action>
        <action path="/*/Edit*" type="com.alodiga.sisac.plans.action.{1}.Edit{2}Action">
            <forward name="success" path="/WEB-INF/pages/{1}/edit{2}.jsp" />
            <forward name="error" path="/WEB-INF/pages/general/generalError.jsp" />
            <forward name="error2" path="/{1}/List{2}.do" />
        </action>

        <action path="/*/SaveAdd*" type="com.alodiga.sisac.plans.action.{1}.Save{2}Action" name="{1}Form" scope="session" input="/WEB-INF/pages/{1}/add{2}.jsp">
            <forward name="success"  path="/{1}/List{2}.do" />
            <forward name="error"  path="/WEB-INF/pages/general/generalError.jsp" />
            <forward name="error2"  path="/{1}/Add{2}.do" />
            <forward name="jsp" path="/WEB-INF/pages/{1}/add{2}.jsp" />
            <forward name="jspEdit" path="/WEB-INF/pages/{1}/edit{2}.jsp" />
            <forward name="edit"  path="/{1}/Edit{2}.do" />
        </action>

        <action path="/*/SaveEdit*" type="com.alodiga.sisac.plans.action.{1}.Save{2}Action" name="{1}Form" scope="session" input="/WEB-INF/pages/{1}/edit{2}.jsp">
            <forward name="success" path="/{1}/List{2}.do" />
            <forward name="error" path="/WEB-INF/pages/general/generalError.jsp" />
            <forward name="edit"  path="/{1}/Edit{2}.do" />
        </action>

        <action path="/*/SaveImport*" type="com.alodiga.sisac.plans.action.{1}.SaveImport{2}Action" name="import{2}Form" scope="session" input="/WEB-INF/pages/{1}/edit{2}.jsp">
            <forward name="success" path="/{1}/List{2}.do" />
            <forward name="error" path="/WEB-INF/pages/{1}/import{2}.jsp" />
            <forward name="fail" path="/{1}/Import{2}.do" />
        </action>
        <action path="/*/Finalize*" type="com.alodiga.sisac.plans.action.{1}.Finalize{2}Action" scope="session" input="/WEB-INF/pages/{1}/list{2}.jsp">
            <forward name="success" path="/{1}/List{2}.do" />
            <forward name="error" path="/WEB-INF/pages/general/generalError.jsp" />
        </action>

        <action path="/*/Delete*" type="com.alodiga.sisac.plans.actions.{1}.Batch{2}Action" name="listForm" scope="request" input="/WEB-INF/pages/{1}/list{2}.jsp">
            <forward name="success" path="/{1}/List{2}.do" />
            <forward name="error" path="/{1}/List{2}.do" />
        </action>

        <action path="/*/Enable*" type="com.alodiga.sisac.plans.action.{1}.Batch{2}Action" name="listForm" scope="request" input="/WEB-INF/pages/{1}/list{2}.jsp">
            <forward name="success" path="/{1}/List{2}.do" />
            <forward name="error" path="/{1}/List{2}.do" />
        </action>

        <action path="/*/Disable*"  type="com.alodiga.sisac.plans.action.{1}.Batch{2}Action" name="listForm" scope="request" input="/WEB-INF/pages/{1}/list{2}.jsp">
            <forward name="success" path="/{1}/List{2}.do" />
            <forward name="error" path="/{1}/List{2}.do" />
        </action>

        <action path="/reloadCache/ReloadCache"  type="com.alodiga.sisac.plans.action.reloadCache.ReloadCacheAction" scope="request" input="/WEB-INF/pages/reloadCache/reloadCache.jsp">
            <forward name="success" path="/WEB-INF/pages/reloadCache/reloadCache.jsp" />
            <forward name="error" path="/WEB-INF/pages/reloadCache/reloadCache.jsp" />
        </action>
        <action name="planForm" path="/*/ChangePlanAsDefault" scope="request" type="com.alodiga.sisac.plans.action.plan.ChangePlanAsDefaultAction">
            <forward name="success" path="/plan/ListPlan.do" />
            <forward name="error" path="/plan/ListPlan.do" />
        </action>

    </action-mappings>

    <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>

    <message-resources parameter=""/>
    
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
        <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
        <set-property property="moduleAware" value="true" />
    </plug-in>
    <!-- ========================= Validator plugin ================================= -->
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
      <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
</struts-config>

我的JSP:

<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<tiles:insert page="/WEB-INF/layouts/rightLayout.jsp">
    <tiles:put name="html-headers" type="String">
        <script type="text/javascript" src="<%= request.getContextPath()%>/js/ajax/utilsPlan.js"></script>
    </tiles:put>
    <tiles:put name="body" type="String">
        <div id="contenido">
            <div class="ruta">
                <p><a target="_parent" href="<%= request.getContextPath()%>/Welcome.do">Módulo de Planes</a> &gt; Números de Acceso</p>
            </div>
            <p>&nbsp;</p>
            <table width="31%" border="0" cellpadding="0" cellspacing="1"
                   class="tbltitcat">
                <tr>
                    <td width="40%" class="tdtitcat">Números de Acceso</td>
                </tr>
            </table>
            <logic:present name="errorMsgs"><div class="menserror"><bean:write name="errorMsgs" /></div></logic:present>
            <logic:present name="successMsgs"><div class="mensexito"><bean:write name="successMsgs" /></div></logic:present>
            <logic:present name="infoMsgs"><div class="mensinfo"><bean:write name="infoMsgs" /></div></logic:present>
            <html:form action="/dn/SaveImportDn" styleId="dnForm" method="POST" enctype="multipart/form-data">
                <table width="100%" border="0" cellspacing="1" cellpadding="0">
                    <tr>
                        <td class="tdtit">Empresa</td>
                        <td>
                            <html:select styleId="enterpriseId" property="enterpriseId" styleClass="inputcampotxt" onchange="showSegments();">
                                <html:options collection="enterprises" property="id" labelProperty="name" />
                            </html:select>
                        </td>
                    </tr>
                    <tr>
                        <td width="30%" class="tdtit">Segmento</td>
                        <td>
                            <div id="segmentsDiv">
                                <html:select styleId="segmentId" property="segmentId" styleClass="inputcampotxt" onchange="showServicesBySegment();">
                                    <html:options collection="segments" property="id" labelProperty="name"/>
                                </html:select>
                            </div>
                            <span class="menstxterror"><html:errors property="segmentId" /></span>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdtit">Servicio</td>
                        <td>
                            <div id="servicesDiv">
                                <html:select styleId="serviceId" property="serviceId" styleClass="inputcampotxt">
                                    <html:options collection="services" property="id" labelProperty="name"/>
                                </html:select>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td width="30%" class="tdtit">Archivo Excel *</td>
                        <td><html:file property="xlsFile" styleClass="inputcampotxt" size="40" /></td>
                    </tr>
                    <tr>
                        <td colspan="2">
                        <input name="segments" type="submit" class="button" alt="boton" value="Aceptar"/></td>
                    </tr>
                </table>
            </html:form>
        </div>
        <div class="contenidofin">&nbsp;</div>
    </tiles:put>
</tiles:insert>
java jsp javabeans struts struts-1
1个回答
2
投票

在 JSP 页面的任何范围内都找不到

segments
的值。可能是您在从操作返回此 JSP 之前忘记初始化该值,或者您直接访问 JSP,或者您遇到验证错误并将此 JSP 配置为
input
。在最后一种情况下,您应该在表单的
validate()
方法中初始化集合。

还有另一种方式通过

html:select
html:optionsCollection
提供选项。

<html:optionsCollection property="segments" label="name" value="id" />
© www.soinside.com 2019 - 2024. All rights reserved.