javabean是一个自定义类,通常表示真实数据,并通过公共getter和setter方法封装私有属性。例如,用户,产品,订单等。
我找不到一种方法来验证 long 变量何时带有空值。我必须验证 BigDecimal 和 long 变量,对于 BigDecimal 我的自定义注释工作正常,但对于 long 类型则不行...
在我的应用程序中,我遇到了一个问题,当类中的 getter 仅在接口中默认时(Java 8 功能),结果不会有 Java Beans 属性。 IE。对于普通方法调用...
Spring生成同一个实例“MyRepository”的两个bean
我对 Spring Boot 相当“陌生”,需要一些有关 CrudRepositories 的帮助。 我的问题如下:当我想启动我的 Spring Boot 应用程序时,它启动得很好,创建了所有表格...
我面临请求范围 Java bean 和异步处理的问题。 我正在开发一个基于微服务的应用程序,其中的服务通过 REST API 相互通信。授权b...
我有一个 Spring Web 应用程序。这是一个简单的结构来解释我的问题 爪哇/ └── com/ └── 例子/ ├── 控制器/ │ └── MyController.java // REST 控制器 ├──
jakarta.el.ELException:java.lang.NullPointerException:无法调用“String.trim()”,因为“in”为空
我正在学习JSP和JavaBeans。 我编写了一个简单的网络应用程序来计算贷款偿还额。应用程序使用用户输入(来自表单)正确设置 bean 的字段。豆子里还含有一个我...
我使用的是Struts 2,我知道Struts根据请求在action中创建声明的bean对象,以便它可供action使用。 我一直在研究了解哪个
我现在正在使用 JSP,但我的 bean 有一些问题。 我有这样的消息: javax.servlet.jsp.JspException:无法在名称段下找到 bean 支柱配置: 我现在正在使用 JSP,但我在使用 Bean 时遇到了一些问题。 我有这样的消息: javax.servlet.jsp.JspException:无法在名称段下找到 bean 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> > Números de Acceso</p> </div> <p> </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"> </div> </tiles:put> </tiles:insert> 在 JSP 页面的任何范围内都找不到 segments 的值。这可能是因为您在从操作返回此 JSP 之前忘记初始化该值,或者您直接访问 JSP,或者您遇到验证错误并将此 JSP 配置为 input。在最后一种情况下,您应该在表单的 validate() 方法中初始化集合。 还有另一种方式通过 html:select 为 html:optionsCollection 提供选项。 <html:optionsCollection property="segments" label="name" value="id" />
我正在尝试使用 bean 来显示预定义消息,我已经创建了以下文件,但是当我输入 时,它遇到了以下错误 我正在尝试使用 bean 来显示预定义消息,我创建了以下文件,但是当我输入 <me 时,它遇到以下错误,自动代码生成器不显示 <message - resources> 标签! org.apache.jasper.JasperException:找不到 Struts 调度程序。 这通常是由于使用 Struts 标签而没有关联的过滤器造成的。 Struts 标签仅在请求通过其 servlet 过滤器时才可用,该过滤器会初始化该标签所需的 Struts 调度程序。 - [未知位置] 注意: 异常的完整堆栈跟踪及其根本原因可在 GlassFish Server 开源版 3.1.2.2 日志中找到。 struts.xml <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts-config> <!-- Configuration for the default package. --> <message-resources parameter="com/myapp/struts/messages"/> <package name="default" extends="struts-default"> <result-types> <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/> </result-types> <action name="register"> <result type="tiles">register</result> </action> </package> </struts-config> register.jsp: <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <div id="Header"> <bean:message key="welcome.loggedin"/> </div> messages.properties: # -- welcome -- welcome.loggedin=You are logged in. welcome.heading=Struts Applications in Netbeans! welcome.message=It's easy to create Struts applications with NetBeans. 我想问题出在我的 jar 文件上 commons-digester-1.8.1.jar commons-fileupload-1.2.1.jar commons-io-1.3.2.jar commons-lang-2.1.jar commons-logging-1.1.jar displaytag-1.2.jar displaytag-export-poi-1.2.jar displaytag-portlet-1.2.jar freemarker-2.3.13.jar jdom-1.1.jar jstl-1.2.jar junit-3.8.1.jar ognl-2.6.11.jar pagertag.jar sqlite-jdbc-3.7.2.jar struts2-convention-plugin-2.1.6.jar struts2-core-2.1.6.jar struts2-dojo-plugin-2.1.2.jar struts2-tiles-plugin-2.1.6.jar tiles-api-2.1.2.jar tiles-compat-2.1.2.jar tiles-core-2.1.2.jar tiles-jsp-2.1.2.jar tiles-servlet-2.1.2.jar struts-taglib-1.3.10.jar xwork-2.1.2.jar <bean:message key=标签是一个Struts1标签,在Struts2中它被替换为<s:text name=。除非您没有足够的理由运行这两个框架,否则您不应该使用 Struts1 标签。 您正在 Struts 2 应用程序中使用 Struts 1 标签。不。 Struts 1 和 Struts 2 是两个完全不同的 Web 框架。 这里是关于 i18n 的 Struts2 文档页面。
如何在 Struts 1 中使用带有 <html:select> 标签的选项集合?
以下 TreeMap 包含我传递的数据库中的所有值 MaptreeMap = new TreeMap(map); 迭代器mapIterator = mapSet.it...
在 Struts 1 中将 Java bean 转换为 JSON 字符串
我想使用Struts 来呈现JSP 页面中的内容。 我有实现可序列化的 Java Bean 类: 公共类 MyPOJO 实现可序列化 { 字符串名称; 整数值; // 瞧...
javax.servlet.ServletException:javax.crypto.IllegalBlockSizeException:使用填充密码解密时,输入长度必须是 16 的倍数
如何解决以下问题。 动作.java: byte[] decValue = c.doFinal(decordedValue); account_bean fromBean = (account_bean) 形式; String account_name = fromBean.getName(); 字符串加密_密码...
保存JSP表单时出错:NoSuchMethodError: com.abc.bean.enqformbean.EnqBean.setEnqAllocation(I)V
将表单数据保存到 Oracle 数据库时出现问题。 首先,问题是: org.hibernate.PropertyAccessException:空值被分配给 的原始类型 setter 的属性 com.abc.b...
如何在Java中传递(request,response)等JSP隐式对象。 我想在Java代码中访问JSP隐式对象。 请建议如何实现这一目标? 我的Java代码是: 包测试。这里; 导入...
如何在Java中传递(request,response)等JSP隐式对象。 我想在Java代码中访问JSP隐式对象。 请建议如何实现这一目标? 我的Java代码是: 包测试。这里; 导入...
首先,我使用Struts 2 和Java。我试图让我的 LoginUser 操作类将信息传递给 UserBean Java Bean。 当 LoginUser 操作执行时,fullName 的 bean 值为
我在 Struts 1 表单上有一些单选按钮: 我在 Struts 1 表单上有一些单选按钮: <input type="radio" name="productId" value="31415" /> <input type="radio" name="productId" value="31416" /> 然后在 Action 类中我可以很好地从表单中获取值。例如,如果我选择第一个单选按钮,则 myForm.getProductId() 返回 31415。 问题: Struts 1 中是否有一种方法可以告诉通过索引选择哪个输入字段,同时保留当前功能? (在最坏的情况下我知道我可以创建一个新的隐藏字段,其中包含所选的单选按钮并从 JavaScript 更新该字段,但我也想避免这种方式。) 说明: 单选按钮是基于集合创建的,但由于某种原因,集合的元素有时没有产品 ID,因此如果有多个这样的元素,那么我无法判断选择了哪个单选按钮。但我想知道即使在这些情况下,如何提高系统的容错能力。 (我对集合中的元素没有权力,它们来自网络服务。) 您可以使用索引属性作为输入字段的索引名称。 对于索引属性,BeanUtils.populate() 使用请求参数的名称来确定调用正确的 setter 方法 ActionForm 使用索引名称 <input type="radio" name="productId[0]" value="31415" /> <input type="radio" name="productId[1]" value="31416" /> 定义索引属性 private String[] productId; public String getProductId(int index) { return productId[index]; } public void setProductId(int index, String productId) { productId[index] = productId; } public String[] getProductId( ) { return productId; }
我现在正在使用 JSP,但我在使用 Bean 时遇到了一些问题。 我有这样的消息: javax.servlet.jsp.JspException:无法在名称段下找到 bean 支柱配置: 我现在正在使用 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> > Números de Acceso</p> </div> <p> </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"> </div> </tiles:put> </tiles:insert> 在 JSP 页面的任何范围内都找不到 segments 的值。可能是您在从操作返回此 JSP 之前忘记初始化该值,或者您直接访问 JSP,或者您遇到验证错误并将此 JSP 配置为 input。在最后一种情况下,您应该在表单的 validate() 方法中初始化集合。 还有另一种方式通过 html:select 为 html:optionsCollection 提供选项。 <html:optionsCollection property="segments" label="name" value="id" />