bean:message

本文介绍了Struts框架中如何使用bean:message标签实现国际化。通过直接或间接指定messagekey,可以从不同语言版本的资源文件中获取对应的消息。文章还展示了如何在Struts配置文件中设置资源文件,并提供了示例代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 bean:message标签用来从指定的locale中取回国际化的消息并输出,在这个过程中我们还可以传递五个以内的参数。message key可以通过key直接指定,也可以通过name和property间接的指定。

bean:message标签有两种指定message key的方式,一是通过key属性直接指定;二是通过name和property属性间接的指定,其中message key是在message resources文件中定义的。

我们可以在struts-config.xml文件中使用<message-resources>来设置message resources文件。

为了介绍该标签我使用了三个message resources文件,三个文件的名字分别为Resources.properties、Resources_en.properties和Resources_zh.properties。在struts-config.xml文件中的设置(这里不用设置三个,struts会依据locale自动找到对应的文件)如下:

<message-resources parameter="Resources" />
三个message resources文件中定义的message key为:

<!-- Resources.properties -->
resource=Resources.properties.
from=Resources.properties.
<!-- Resources_en.properties -->
from=Resources_en.properties.
<!-- Resources_zh.properties
  因为文件的编码被限制为ISO8859所以要有汉字必须用jdk的native2ascii提前转换
-->
from=Resources_zh.properties.
下面的代码片段示例了bean:message标签的用法:

<bean:message key="from"/><br/>
<bean:message key="resource"/><br/>
<html:link action="/locale?language=en">English</html:link>
<html:link action="/locale?language=zh">Chinese</html:link>
上面的代码中含有改变locale的两个html:link标签,要使它们工作您的struts-config.xml文件中必须含有下面定义的form和action:

<form-bean name="localeForm"
    type="org.apache.struts.action.DynaActionForm">
  <form-property name="language" type="java.lang.String" />
  <form-property name="country" type="java.lang.String" />
  <!--action成功后要跳到那里-->
  <form-property name="page"  type="java.lang.String"
    initial="/message.jsp"/>
</form-bean>
 
<action path="/locale" type="org.apache.struts.actions.LocaleAction"
  name="localeForm" scope="request">
</action>
在不同的locale下我们得到了如下的两个结果:

在locale为zh时的结果:
Resources_zh.properties.
Resources.properties.
在locale为en时的结果: 
Resources_en.properties.
Resources.properties.
让我们来看一下在locale为zh时如何得到的是上面的结果。因为locale为zh所以<bean:message key="from"/><br/>先找Resources_zh.properties这个文件从中得到form键的值。而<bean:message key="resource"/><br/>也会先找Resources_zh.properties这个文件但这次没有找到resource键,这时Struts会到Resources.properties这个文件中找,很幸运这里找到了。如果还没有找到,或message resource文件不存在就会抛出异常。当locale为en时类似,您可以自己试试。

本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/AWUSOFT/archive/2008/05/16/2452874.aspx

<%@ page contentType=“text/html; charset=UTF-8”%> <%@ taglib uri=“/WEB-INF/struts-logic.tld” prefix=“logic”%> <%@ taglib uri=“/WEB-INF/struts-bean.tld” prefix=“bean”%> <%@ taglib uri=“/WEB-INF/struts-html.tld” prefix=“html”%> <%@ taglib uri=“/WEB-INF/app.tld” prefix=“app”%> <%@page import=“java.util.List”%> <input name=“riskCode” type=“hidden” value=“<%=request.getAttribute(“riskCode”)%>”> <input name=“planCode” type=“hidden” value=“<%=request.getAttribute(“planCode”)%>”> <input name=“itemNo” type=“hidden” value=“<%=request.getAttribute(“itemNo”)%>”> <input name=“maxGuItemKindItemKindNo” type=“hidden” value=“<%=request.getAttribute(“maxItemKindNo”)%>” /> <input name=“maxGuKindLimitSerialNo” type=“hidden” value=“<%=request.getAttribute(“maxGuKindLimitSerialNo”)%>” /> <input name=“maxGuKindDeductibleDeductibleNo” type=“hidden” value=“<%=request.getAttribute(“maxGuKindDeductibleDeductibleNo”)%>” /> <jsp:include page=“/prpall/plugin/common/riskclass/99/thirdAndMainKind/ItemEngineeringKind_Data.jsp”/> <jsp:include page=“/prpall/plugin/common/riskclass/07/itemengineering/ThirdKindLimitKind_Data.jsp” /> <jsp:include page=“/prpall/plugin/common/riskclass/07/itemengineering/SubKindLimitKind_Data.jsp” /> <jsp:include page=“/prpall/plugin/common/riskclass/07/itemengineering/ItemEngineeringLimit_Data.jsp” /> <script type="text/javascript"> var GuKindLimitLimitA ="<bean:message key="GuKindLimitDto.LimitLimit"/>"; </script> <!-- 物质损失 --> <input name="SubOrThirdFlag" type="hidden" value = "0"> <table id="ItemKind" name="ItemKind" class="common" cellpadding="1" cellspacing="1" border="0"> <thead> <tr style="display: none"> <td width="18%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="12%" align="center"> </td> <td width="12%" align="center"> </td> <td width="13%" align="center"> </td> </tr> <tr class="top01"> <td align="left" colspan="9"><strong><bean:message key="GuItemKindDto.kindName" /></strong></td> </tr> <tr> <!-- 机身损失 --> <td class="left" colspan="9"><strong> <bean:message key="prompt.materialFuselageLoss"/> <%-- 第一部分:机身损失--%> </strong></td> </tr> <tr> <td width="18%" class="white" align="center"><bean:message key="GuItemKindDto.itemCode" /> <font color="red">*</font></td> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.numberSumInsured"/> <font color="red">*</font></td> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.sumInsured" /> <font color="red">*</font></td> <logic:equal name='ggRiskDto' property='calculator' value='100'> <TD class="white" align="center" width="9%"><bean:message key="GuItemKindDto.rate"/>(%) <font color="red">*</font></TD> </logic:equal> <logic:notEqual name='ggRiskDto' property='calculator' value='100'> <TD class="white" align="center" width="9%"><bean:message key="GuItemKindDto.rate"/>(‰) <font color="red">*</font></TD> </logic:notEqual> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.shortRateFlag" /> <font color="red">*</font></td> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.shortRate" /></td> <td width="12%" class="white" align="center"><bean:message key="GuItemKindDto.uwPremium" /></td> <td width="12%" class="white" align="center"><bean:message key="GuItemKindDto.grossPremium" /> <font color="red">*</font></td> <td width="13%" class="white" align="center"></td> </tr> </thead> <tbody> <bean:size id="listMainItemLength" name="guItemKindMainList" /> <% List guItemKindDtoList = (List) request.getAttribute("guItemKindMainList"); if (guItemKindDtoList != null) { int lengthList = guItemKindDtoList.size(); for (int index = 0; index < lengthList; index++) { request.setAttribute("guItemKindDto", guItemKindDtoList.get(index)); %> <logic:notEmpty name = "guItemKindDto" property="itemDetailCode"> <logic:equal parameter="businessType" value="Endor"> <bean:define name="guItemKindDto" property="guPolicyItemKindDto" id="guPolicyItemKindDto" /> </logic:equal> <tr> <td class="white"> <input name="GuItemKindFlag" type="hidden" endorFlag="B" value="<bean:write name='guItemKindDto' property='flag'/>" title="<bean:write name='guPolicyItemKindDto' property='flag'/>" > <input name="GuItemKindProjectCode" type="hidden" value="<bean:write name='guItemKindDto' property='projectCode'/>"> <logic:present name="guItemKindDto" property="subProposalNo"> <input name="GuItemKindSubProposalNo" type="hidden" value="<bean:write name='guItemKindDto' property='subProposalNo'/>"> </logic:present> <logic:present name="guItemKindDto" property="countFlag"> <logic:notEqual name="guItemKindDto" property="countFlag" value="0"> <input name="GuItemKindCountFlag" type="hidden" value="<bean:write name='guItemKindDto' property='countFlag'/>"> </logic:notEqual> </logic:present> <input name="GuItemKindSurrenderInd" type="hidden" value="0"> <input name="GuItemKindItemNo" type="hidden" value="<%=request.getAttribute("itemNo")%>"> <input name="GuItemKindItemDetailNo" type="hidden" value="<bean:write name='guItemKindDto' property='itemDetailNo'/>"> <input name="GuItemKindKindCode" type="hidden" value="<bean:write name='guItemKindDto' property='kindCode'/>"> <input name="GuItemKindKindName" type="hidden" value="<bean:write name='guItemKindDto' property='kindName'/>"> <input name="GuItemKindPlanCode" type="hidden" value="<bean:write name='guItemKindDto' property='planCode'/>"> <input name="GuItemKindRiskCode" type="hidden" value="<bean:write name='guItemKindDto' property='riskCode'/>"> <input name="GuItemKindCompanyCode" type="hidden" value="<%=request.getAttribute("companyCode")%>"> <input name="GuItemKindItemCode" type="hidden" value="<bean:write name='guItemKindDto' property='itemCode'/>"> <input name="GuItemKindStartDate" type="hidden" value="<bean:write name='guItemKindDto' property='startDate'/>" title="<bean:write name='guPolicyItemKindDto' property='startDate'/>"> <input name="GuItemKindEndDate" type="hidden" value="<bean:write name='guItemKindDto' property='endDate'/>" title="<bean:write name='guPolicyItemKindDto' property='endDate'/>"> <input name="GuItemKindCurrency" type="hidden" value="<bean:write name='guItemKindDto' property='currency'/>" title="<bean:write name='guPolicyItemKindDto' property='currency'/>" > <input name="GuItemKindItemKindNo" type="hidden" title="<bean:write name='guItemKindDto' property='itemKindNo'/>" value="<bean:write name='guItemKindDto' property='itemKindNo'/>"> <input name="GuItemKindReSpecialInd" type="hidden" value="<bean:write name='guItemKindDto' property='reSpecialInd'/>"> <input name="GuItemKindItemDetailCode" class="codecode" type="text" style="width: 30%" title="<bean:write name='guPolicyItemKindDto' property='itemDetailCode'/>" value="<bean:write name='guItemKindDto' property='itemDetailCode'/>" ondblclick="getField(this, 'ItemKind', '<bean:message key='alert.message.sameItemDetailCode' />');code_CodeSelect(this,'itemDetailCodeByRiskCode','0,1,1,3,4,8,9','Y','riskCode=<%=request.getAttribute("riskCode")%>','setGuItemKindItemDetailCodeOnchange();');" onkeyup="getField(this, 'ItemKind', '<bean:message key='alert.message.sameItemDetailCode' />');code_CodeSelect(this,'itemDetailCodeByRiskCode','0,1,1,3,4,8,9','Y','riskCode=<%=request.getAttribute("riskCode")%>','setGuItemKindItemDetailCodeOnchange();');" onchange="getField(this, 'ItemKind', '<bean:message key='alert.message.sameItemDetailCode' />');code_CodeChange(this,'itemDetailCodeByRiskCode','0,1,1,3,4,8,9','Y','riskCode=<%=request.getAttribute("riskCode")%>','setGuItemKindItemDetailCodeOnchange();');"> <input name="GuItemKindItemDetailList" class="codename" type="text" style="width: 65%" title="<bean:write name='guPolicyItemKindDto' property='itemDetailList'/>" value="<bean:write name='guItemKindDto' property='itemDetailList'/>"> <input name="GuItemKindKindInd" type="hidden" value="<bean:write name='guItemKindDto' property='kindInd'/>"> </td> <td class="white"> <input name="GuItemKindCalculateInd" class="codecode" type="text" style="width:30%" title="<bean:write name='guPolicyItemKindDto' property='calculateInd'/>" value="<bean:write name='guItemKindDto' property='calculateInd'/>" ondblclick="getField(this,'ItemKind');code_CodeSelect(this,'calculateInd','0,1','Y','02,CalculateInd','setGuItemKindCalculateIndOnchange();');" onkeyup="getField(this,'ItemKind');code_CodeSelect(this,'calculateInd','0,1','Y','02,CalculateInd','setGuItemKindCalculateIndOnchange();');" onchange="getField(this,'ItemKind');code_CodeChange(this,'calculateInd','0,1','Y','02,CalculateInd','setGuItemKindCalculateIndOnchange();');"> <input name="GuItemKindCalculateIndName" class="readonly" type="text" style="width:65%" readonly title="<app:localeName name="guPolicyItemKindDto" property="calculateInd,CalculateInd" codeType="ggCodeCodeName" filter="true" />" value="<app:localeName name="guItemKindDto" property="calculateInd,CalculateInd" codeType="ggCodeCodeName" filter="true" />"> </td> <td class="white"> <input name="GuItemKindSumInsured" class="common01" type="text" style="width: 100%" title="<bean:write name='guPolicyItemKindDto' property='sumInsured'/>" value="<bean:write name='guItemKindDto' property='sumInsured'/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','')"> </td> <td class="white"> <input name="GuItemKindRate" class="common01" type="text" style="width: 100%" title="<bean:write name='guPolicyItemKindDto' property='rate' format="#,##0.000000"/>" value="<bean:write name='guItemKindDto' property='rate' format="#,##0.000000"/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','')"> <input name="GuCalculator" type="hidden" value="100"> </td> <td class="white"> <input name="GuItemKindShortRateFlag" class="codecode" type="text" style="width: 30%" title="<bean:write name='guPolicyItemKindDto' property='shortRateFlag'/>" value="<bean:write name='guItemKindDto' property='shortRateFlag'/>" ondblclick="getField(this, 'ItemKind', '<bean:message key="alert.message.kindcodeMustInput"/>', '<bean:message key="alert.message.zeroError"/>');code_CodeSelect(this,'shortRateFlag','0,1','Y','02,ShortRateFlag','changeGuItemKindShortRateFlag();');" onkeyup="getField(this, 'ItemKind', '<bean:message key="alert.message.kindcodeMustInput"/>', '<bean:message key="alert.message.zeroError"/>');code_CodeSelect(this,'shortRateFlag','0,1','Y','02,ShortRateFlag','changeGuItemKindShortRateFlag();');" onchange="getField(this, 'ItemKind', '<bean:message key="alert.message.kindcodeMustInput"/>', '<bean:message key="alert.message.zeroError"/>');code_CodeChange(this,'shortRateFlag','0,1','Y','02,ShortRateFlag','changeGuItemKindShortRateFlag();');"> <input name="GuItemKindShortRateFlagName" class="readonly" type="text" style="width: 65%" readonly title="<app:localeName name="guItemKindDto" property="shortRateFlag,ShortRateFlag" codeType="ggCodeCodeName" filter="true" />" value="<app:localeName name="guItemKindDto" property="shortRateFlag,ShortRateFlag" codeType="ggCodeCodeName" filter="true" />"> </td> <td class="white"> <input name="GuItemKindShortRate" type="hidden" value="<bean:write name='guItemKindDto' property='shortRate' format="0.00"/>" title="<bean:write name='guPolicyItemKindDto' property='shortRate' format="0.00"/>"> <input name="GuItemKindShortRateNumerator" class="common01" readonly="readonly" type="text" style="width: 42%" value="<bean:write name='guItemKindDto' property='shortRateNumerator' format="#"/>" title="<bean:write name='guPolicyItemKindDto' property='shortRateNumerator' format="#"/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','')">/ <input name="GuItemKindShortRateDenominator" class="common01" readonly="readonly" type="text" style="width: 42%" value="<bean:write name='guItemKindDto' property='shortRateDenominator'/>" title="<bean:write name='guPolicyItemKindDto' property='shortRateDenominator'/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','')"> </td> <td class="white"> <input name="GuItemKindUwPremium" class="readonly" type="text" style="width:100%" readonly title="<bean:write name='guPolicyItemKindDto' property='uwPremium'/>" value="<bean:write name='guItemKindDto' property='uwPremium'/>" onchange=" "> <input name="GuItemKindOriginUWPremium" class="common01" type="hidden" style="width: 100%" value="<bean:write name='guItemKindDto' property='originUWPremium'/>"> </td> <td class="white"> <input name="GuItemKindGrossPremium" class="common" type="text" style="width: 100%" title="<bean:write name='guPolicyItemKindDto' property='grossPremium'/>" value="<bean:write name='guItemKindDto' property='grossPremium'/>" onchange=" "> <input name="GuItemKindOriginGrossPremium" class="common01" type="hidden" value="<bean:write name='guItemKindDto' property='originGrossPremium'/>"> </td> <td class="white" align="center"> <INPUT name="button_ItemKind_Delete" class="smallbutton" type="button" value="<bean:message key="button.delete"/>" ind="ind" onclick="deleteRowInTable(this,'ItemKind','1',1);afterEndorDeleteItemKind(this, '');"> </td> </tr> </logic:notEmpty> <% } } %> </tbody> <tfoot> <TR> <TD class="title02" colspan="9"> <P align="left"><input name="button_ItemKind_Insert" class="button" type="button" style="cursor:hand" ind="ind" value="<bean:message key='button.add'/>" onclick="insertRowInTable(this,'ItemKind',1);"> </P> </TD> </TR> </tfoot> </table> <!-- 特种风险赔偿限额 --> <logic:notEqual name=‘ggRiskDto’ property=‘riskCode’ value=‘9929’> <jsp:include page=“/prpall/plugin/common/riskclass/07/itemengineering/ItemEngineeringLimit.jsp” /> </logic:notEqual> <!-- 第三者责任 --> <table id="ItemKindThird" name="ItemKindThird" class="common" cellpadding="1" cellspacing="1"> <thead> <tr style="display: none"> <td width="18%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="12%" align="center"> </td> <td width="12%" align="center"> </td> <td width="13%" align="center"> </td> </tr> <tr> <td class="left" colspan="9"><strong><bean:message key="prompt.thirdPartyLibility2"/></strong></td> </tr> <tr> <td width="18%" class="white" align="center"><bean:message key="GuItemKindDto.kindCode" /> <font color="red">*</font></td> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.numberSumInsured"/> <font color="red">*</font></td> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.thirdSumInsured" /> <font color="red">*</font></td> <logic:equal name='ggRiskDto' property='calculator' value='100'> <TD class="white" align="center" width="9%"><bean:message key="GuItemKindDto.rate"/>(%) <font color="red">*</font></TD> </logic:equal> <logic:notEqual name='ggRiskDto' property='calculator' value='100'> <TD class="white" align="center" width="9%"><bean:message key="GuItemKindDto.rate"/>(‰) <font color="red">*</font></TD> </logic:notEqual> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.shortRateFlag" /> <font color="red">*</font></td> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.shortRate" /></td> <td width="12%" class="white" align="center"><bean:message key="GuItemKindDto.uwPremium" /></td> <td width="12%" class="white" align="center"><bean:message key="GuItemKindDto.grossPremium" /> <font color="red">*</font></td> <td width="13%" class="white" align="center"></td> </tr> </thead> <tbody> <% List guThirdItemKindDtoList = (List) request.getAttribute("guItemKindThirdList"); if (guThirdItemKindDtoList != null) { int lengthThirdList = guThirdItemKindDtoList.size(); for (int index = 0; index < lengthThirdList; index++) { request.setAttribute("guThirdItemKindDto", guThirdItemKindDtoList.get(index)); %> <logic:notEmpty name = "guThirdItemKindDto" property="sumInsured"> <logic:equal parameter="businessType" value="Endor"> <bean:define name="guThirdItemKindDto" property="guPolicyItemKindDto" id="thirdGuPolicyItemKindDto" /> </logic:equal> <tr> <td class="white"> <input name="ThirdGuItemKindFlag" type="hidden" endorFlag="B" value="<bean:write name='guThirdItemKindDto' property='flag'/>" title="<bean:write name='thirdGuPolicyItemKindDto' property='flag'/>"> <input name="ThirdGuItemKindProjectCode" type="hidden" value="<bean:write name='guThirdItemKindDto' property='projectCode'/>"> <input name="ThirdGuItemKindKindCode" class="codecode" type="text" style="width: 30%" readonly title="<bean:write name='thirdGuPolicyItemKindDto' property='kindCode'/>" value="<bean:write name='guThirdItemKindDto' property='kindCode'/>"> <input name="ThirdGuItemKindKindName" class="readonly" type="text" style="width: 65%" readonly title="<bean:write name='thirdGuPolicyItemKindDto' property='kindName'/>" value="<bean:write name='guThirdItemKindDto' property='kindName'/>"> <logic:present name="guThirdItemKindDto" property="subProposalNo"> <input name="ThirdGuItemKindSubProposalNo" type="hidden" value="<bean:write name='guThirdItemKindDto' property='subProposalNo'/>"> </logic:present> <logic:present name="guThirdItemKindDto" property="countFlag"> <logic:notEqual name="guThirdItemKindDto" property="countFlag" value="0"> <input name="ThirdGuItemKindCountFlag" type="hidden" value="<bean:write name='guThirdItemKindDto' property='countFlag'/>"> </logic:notEqual> </logic:present> <input name="ThirdGuItemKindSurrenderInd" type="hidden" value="0"> <input name="ThirdGuItemKindItemNo" type="hidden" value="<%=request.getAttribute("itemNo")%>"> <input name="ThirdGuItemKindItemDetailNo" type="hidden" value="0"> <input name="ThirdGuItemKindPlanCode" type="hidden" value="<bean:write name='guThirdItemKindDto' property='planCode'/>"> <input name="ThirdGuItemKindRiskCode" type="hidden" value="<bean:write name='guThirdItemKindDto' property='riskCode'/>"> <input name="ThirdGuItemKindCompanyCode" type="hidden" value="<%=request.getAttribute("companyCode")%>"> <input name="ThirdGuItemKindItemCode" type="hidden" value="<bean:write name='guThirdItemKindDto' property='itemCode'/>"> <input name="ThirdGuItemKindReSpecialInd" type="hidden" value="<bean:write name='guThirdItemKindDto' property='reSpecialInd'/>"> <input name="ThirdGuItemKindStartDate" type="hidden" value="<bean:write name='guThirdItemKindDto' property='startDate'/>" title="<bean:write name='thirdGuPolicyItemKindDto' property='startDate'/>"> <input name="ThirdGuItemKindEndDate" type="hidden" value="<bean:write name='guThirdItemKindDto' property='endDate'/>" title="<bean:write name='thirdGuPolicyItemKindDto' property='endDate'/>"> <input name="ThirdGuItemKindCurrency" type="hidden" onchange=" " value="<bean:write name='guThirdItemKindDto' property='currency'/>" title="<bean:write name='thirdGuPolicyItemKindDto' property='currency'/>" > <input name="ThirdGuItemKindItemKindNo" type="hidden" title="<bean:write name='thirdGuPolicyItemKindDto' property='itemKindNo'/>" value="<bean:write name='guThirdItemKindDto' property='itemKindNo'/>"> <input name="ThirdGuItemKindItemDetailCode" class="codecode" type="text" style="display:none;width: 30%" title="<bean:write name='thirdGuPolicyItemKindDto' property='itemDetailCode'/>" value="<bean:write name='guThirdItemKindDto' property='itemDetailCode'/>" ondblclick="getField(this, 'ItemKindThird', '<bean:message key='alert.message.sameItemDetailCode' />');code_CodeSelect(this,'itemDetailCodeByRiskCode','0,1','Y','riskCode=<%=request.getAttribute("riskCode")%>','');" onkeyup="getField(this, 'ItemKindThird', '<bean:message key='alert.message.sameItemDetailCode' />');code_CodeSelect(this,'itemDetailCodeByRiskCode','0,1','Y','riskCode=<%=request.getAttribute("riskCode")%>','');" onchange="getField(this, 'ItemKindThird', '<bean:message key='alert.message.sameItemDetailCode' />');code_CodeChange(this,'itemDetailCodeByRiskCode','0,1','Y','riskCode=<%=request.getAttribute("riskCode")%>','');"> <input name="ThirdGuItemKindItemDetailList" class="readonly" type="text" style="display:none;width: 65%" readonly title="<bean:write name='thirdGuPolicyItemKindDto' property='itemDetailList'/>" value="<bean:write name='guThirdItemKindDto' property='itemDetailList'/>"> <input name="ThirdGuItemKindKindInd" type="hidden" value="<bean:write name='guThirdItemKindDto' property='kindInd'/>"> </td> <td class="white"> <input name="ThirdGuItemKindCalculateInd" class="codecode" type="text" style="width:30%" title="<bean:write name='thirdGuPolicyItemKindDto' property='calculateInd'/>" value="<bean:write name='guThirdItemKindDto' property='calculateInd'/>" ondblclick="getField(this,'ItemKindThird');code_CodeSelect(this,'calculateInd','0,1','Y','02,CalculateInd','setGuItemKindCalculateIndOnchange();');" onkeyup="getField(this,'ItemKindThird');code_CodeSelect(this,'calculateInd','0,1','Y','02,CalculateInd','setGuItemKindCalculateIndOnchange();');" onchange="getField(this,'ItemKindThird');code_CodeChange(this,'calculateInd','0,1','Y','02,CalculateInd','setGuItemKindCalculateIndOnchange();');"> <input name="ThirdGuItemKindCalculateIndName" class="readonly" type="text" style="width:65%" readonly title="<app:localeName name="thirdGuPolicyItemKindDto" property="calculateInd,CalculateInd" codeType="ggCodeCodeName" filter="true" />" value="<app:localeName name="guThirdItemKindDto" property="calculateInd,CalculateInd" codeType="ggCodeCodeName" filter="true" />"> </td> <td class="white"> <input name="ThirdGuItemKindSumInsured" class="common01" type="text" style="width: 100%" title="<bean:write name='thirdGuPolicyItemKindDto' property='sumInsured'/>" value="<bean:write name='guThirdItemKindDto' property='sumInsured'/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','Third');"> </td> <td class="white"> <input name="ThirdGuItemKindRate" class="common01" type="text" style="width: 100%" title="<bean:write name='thirdGuPolicyItemKindDto' property='rate' format="#,##0.000000"/>" value="<bean:write name='guThirdItemKindDto' property='rate' format="#,##0.000000"/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','Third');"> <input name="GuCalculator" type="hidden" value="100"> </td> <td class="white"> <input name="ThirdGuItemKindShortRateFlag" class="codecode" type="text" style="width: 30%" title="<bean:write name='thirdGuPolicyItemKindDto' property='shortRateFlag'/>" value="<bean:write name='guThirdItemKindDto' property='shortRateFlag'/>" ondblclick="getField(this, 'ItemKindThird', '<bean:message key="alert.message.kindcodeMustInput"/>', '<bean:message key="alert.message.zeroError"/>');code_CodeSelect(this,'shortRateFlag','0,1','Y','02,ShortRateFlag','changeGuItemKindShortRateFlag();');" onkeyup="getField(this, 'ItemKindThird', '<bean:message key="alert.message.kindcodeMustInput"/>', '<bean:message key="alert.message.zeroError"/>');code_CodeSelect(this,'shortRateFlag','0,1','Y','02,ShortRateFlag','changeGuItemKindShortRateFlag();');" onchange="getField(this, 'ItemKindThird', '<bean:message key="alert.message.kindcodeMustInput"/>', '<bean:message key="alert.message.zeroError"/>');code_CodeChange(this,'shortRateFlag','0,1','Y','02,ShortRateFlag','changeGuItemKindShortRateFlag();');"> <input name="ThirdGuItemKindShortRateFlagName" class="common01" type="text" style="width: 65%" readonly title="<app:localeName name="thirdGuPolicyItemKindDto" property="shortRateFlag,ShortRateFlag" codeType="ggCodeCodeName" filter="true" />" value="<app:localeName name="guThirdItemKindDto" property="shortRateFlag,ShortRateFlag" codeType="ggCodeCodeName" filter="true" />"> </td> <td class="white"> <input name="ThirdGuItemKindShortRate" type="hidden" value="<bean:write name='guThirdItemKindDto' property='shortRate' format="0.00"/>" title="<bean:write name='thirdGuPolicyItemKindDto' property='shortRate' format="0.00"/>"> <input name="ThirdGuItemKindShortRateNumerator" class="common01" readonly="readonly" type="text" style="width: 42%" value="<bean:write name='guThirdItemKindDto' property='shortRateNumerator' format="#"/>" title="<bean:write name='thirdGuPolicyItemKindDto' property='shortRateNumerator' format="#"/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','Third');">/ <input name="ThirdGuItemKindShortRateDenominator" class="common01" readonly="readonly" type="text" style="width: 42%" value="<bean:write name='guThirdItemKindDto' property='shortRateDenominator' format="#"/>" title="<bean:write name='thirdGuPolicyItemKindDto' property='shortRateDenominator' format="#"/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','Third');"> </td> <td class="white"> <input name="ThirdGuItemKindUwPremium" class="readonly" type="text" style="width: 100%" readonly title="<bean:write name='thirdGuPolicyItemKindDto' property='uwPremium'/>" value="<bean:write name='guThirdItemKindDto' property='uwPremium'/>" onchange=" "> <input name="ThirdGuItemKindOriginUWPremium" class="common01" type="hidden" style="width: 100%" value="<bean:write name='guThirdItemKindDto' property='originUWPremium'/>"> </td> <td class="white"> <input name="ThirdGuItemKindGrossPremium" class="common01" type="text" style="width: 100%" title="<bean:write name='thirdGuPolicyItemKindDto' property='grossPremium'/>" value="<bean:write name='guThirdItemKindDto' property='grossPremium'/>" onchange=""> <input name="ThirdGuItemKindOriginGrossPremium" class="common01" type="hidden" value="<bean:write name='guThirdItemKindDto' property='originGrossPremium'/>"> </td> <td class="white" align="center"> <input name="button_ThirdKindLimitKind_Edit" class="smallbutton" type="button" style="cursor: hand" value="<bean:message key="button.limit"/>" onclick="showSubPageForPrpall(this,'span_ThirdKindLimitKind_SubPage');"> <SPAN id="span_ThirdKindLimitKind_SubPage" name="span_ThirdKindLimitKind_SubPage" style="display: none; position: absolute; width: 790; background-color: FFFFFF;"> <jsp:include page="/prpall/plugin/common/riskclass/07/itemengineering/ThirdKindLimitKind.jsp" /> </SPAN> <INPUT name="button_ItemKindThird_Delete" class="smallbutton" type="button" value="<bean:message key="button.delete"/>" ind="ind" onclick="deleteRowInTable(this,'ItemKindThird',1,1);afterEndorDeleteItemKind(this, 'Third', '')"> </td> </tr> </logic:notEmpty> <% } } %> </tbody> <tfoot> <TR> <TD class="title02" colspan="9"> <P align="left"><input name="button_ItemKindThird_Insert" class="button" type="button" style="cursor:hand" ind="ind" value="<bean:message key='button.add'/>" onclick="insertEngineeringThridItemKind(this, 'ItemKindThird', 1, '<bean:message key='alert.message.aThirdKindOfAItem' />')"> </P> </TD> </TR> </tfoot> </table> <!--附加险 --> <table id="ItemKindSub" name="ItemKindSub" class="common" cellpadding="1" cellspacing="1"> <thead> <tr style="display: none"> <td width="18%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="9%" align="center"> </td> <td width="12%" align="center"> </td> <td width="12%" align="center"> </td> <td width="13%" align="center"> </td> </tr> <tr> <td class="left" colspan="9"><strong><bean:message key="GuItemKindDto.subKind"/></strong></td> </tr> <tr> <td width="18%" class="white" align="center"><bean:message key="GuItemKindDto.kindCode" /> <font color="red">*</font></td> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.numberSumInsured"/> <font color="red">*</font></td> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.thirdSumInsured" /> <font color="red">*</font></td> <logic:equal name='ggRiskDto' property='calculator' value='100'> <TD class="white" align="center" width="9%"><bean:message key="GuItemKindDto.rate"/>(%) <font color="red">*</font></TD> </logic:equal> <logic:notEqual name='ggRiskDto' property='calculator' value='100'> <TD class="white" align="center" width="9%"><bean:message key="GuItemKindDto.rate"/>(‰) <font color="red">*</font></TD> </logic:notEqual> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.shortRateFlag" /> <font color="red">*</font></td> <td width="9%" class="white" align="center"><bean:message key="GuItemKindDto.shortRate" /></td> <td width="12%" class="white" align="center"><bean:message key="GuItemKindDto.uwPremium" /></td> <td width="12%" class="white" align="center"><bean:message key="GuItemKindDto.grossPremium" /> <font color="red">*</font></td> <td width="13%" class="white" align="center"></td> </tr> </thead> <tbody> <% List guSubItemKindDtoList = (List) request.getAttribute("guItemKindSubList"); if (guSubItemKindDtoList != null) { int lengthSubList = guSubItemKindDtoList.size(); for (int index = 0; index < lengthSubList; index++) { request.setAttribute("subGuItemKindDto", guSubItemKindDtoList.get(index)); %> <logic:notEmpty name="subGuItemKindDto" property="sumInsured"> <logic:equal parameter="businessType" value="Endor"> <bean:define name="subGuItemKindDto" property="guPolicyItemKindDto" id="subGuPolicyItemKindDto" /> </logic:equal> <tr> <td class="white"> <input name="SubGuItemKindFlag" type="hidden" endorFlag="B" value="<bean:write name='subGuItemKindDto' property='flag'/>" title="<bean:write name='subGuPolicyItemKindDto' property='flag' filter='true'/>"> <input name="SubGuItemKindProjectCode" type="hidden" value="<bean:write name='subGuItemKindDto' property='projectCode'/>"> <logic:present name="subGuItemKindDto" property="subProposalNo"> <input name="SubGuItemKindSubProposalNo" type="hidden" value="<bean:write name='subGuItemKindDto' property='subProposalNo'/>"> </logic:present> <logic:present name="subGuItemKindDto" property="countFlag"> <logic:notEqual name="subGuItemKindDto" property="countFlag" value="0"> <input name="SubGuItemKindCountFlag" type="hidden" value="<bean:write name='subGuItemKindDto' property='countFlag'/>"> </logic:notEqual> </logic:present> <input name="SubGuItemKindSurrenderInd" type="hidden" value="0"> <input name="SubGuItemKindItemNo" type="hidden" value="<%=request.getAttribute("itemNo")%>"> <input name="SubGuItemKindItemDetailNo" type="hidden" value="0"> <input name="SubGuItemKindPlanCode" type="hidden" value="<bean:write name='subGuItemKindDto' property='planCode'/>"> <input name="SubGuItemKindRiskCode" type="hidden" value="<bean:write name='subGuItemKindDto' property='riskCode'/>"> <input name="SubGuItemKindCompanyCode" type="hidden" value="<%=request.getAttribute("companyCode")%>"> <input name="SubGuItemKindItemCode" type="hidden" value="<bean:write name='subGuItemKindDto' property='itemCode'/>"> <input name="SubGuItemKindReSpecialInd" type="hidden" value="<bean:write name='subGuItemKindDto' property='reSpecialInd'/>"> <input name="SubGuItemKindStartDate" type="hidden" value="<bean:write name='subGuItemKindDto' property='startDate'/>" title="<bean:write name='subGuPolicyItemKindDto' property='startDate'/>"> <input name="SubGuItemKindEndDate" type="hidden" value="<bean:write name='subGuItemKindDto' property='endDate'/>" title="<bean:write name='subGuPolicyItemKindDto' property='endDate'/>"> <input name="SubGuItemKindDiscount" type="hidden" value="<bean:write name='subGuItemKindDto' property='discount'/>"> <input name="SubGuItemKindCurrency" type="hidden" onchange=" " value="<bean:write name='subGuItemKindDto' property='currency'/>" title="<bean:write name='subGuPolicyItemKindDto' property='currency'/>" > <input name="SubGuItemKindItemKindNo" type="hidden" title="<bean:write name='subGuPolicyItemKindDto' property='itemKindNo'/>" value="<bean:write name='subGuItemKindDto' property='itemKindNo'/>"> <input name="SubGuItemKindItemDetailCode" class="codecode" type="text" style="display:none;width: 30%" title="<bean:write name='subGuPolicyItemKindDto' property='itemDetailCode'/>" value="<bean:write name='subGuItemKindDto' property='itemDetailCode'/>" ondblclick="getField(this, 'ItemKindSub', '<bean:message key='alert.message.sameItemDetailCode' />');code_CodeSelect(this,'itemDetailCodeByRiskCode','0,1','Y','riskCode=<%=request.getAttribute("riskCode")%>','');" onkeyup="getField(this, 'ItemKindSub', '<bean:message key='alert.message.sameItemDetailCode' />');code_CodeSelect(this,'itemDetailCodeByRiskCode','0,1','Y','riskCode=<%=request.getAttribute("riskCode")%>','');" onchange="getField(this, 'ItemKindSub', '<bean:message key='alert.message.sameItemDetailCode' />');code_CodeChange(this,'itemDetailCodeByRiskCode','0,1','Y','riskCode=<%=request.getAttribute("riskCode")%>','');"> <input name="SubGuItemKindItemDetailList" class="readonly" type="text" style="display:none;width: 65%" readonly title="<bean:write name='subGuPolicyItemKindDto' property='itemDetailList'/>" value="<bean:write name='subGuItemKindDto' property='itemDetailList'/>"> <input name="SubGuItemKindKindCode" class="codecode" type="text" style="width:30%" title="<bean:write name='subGuPolicyItemKindDto' property='kindCode'/>" value="<bean:write name='subGuItemKindDto' property='kindCode'/>" ondblclick="getField(this, 'ItemKindSub', '<bean:message key='alert.message.itemkind' />');code_CodeSelect(this,'getKindCodeWithIndNew','0,1,2,3,4,8,9,','Y','riskCode='+fm.SubGuItemKindRiskCode[1].value+',kindInd=2,productEdition=fm.productEdition.value','');changeSubKindCodeCallBack(this);" onkeyup="getField(this, 'ItemKindSub', '<bean:message key='alert.message.itemkind' />');code_CodeSelect(this,'getKindCodeWithIndNew','0,1,2,3,4,8,9','Y','riskCode='+fm.SubGuItemKindRiskCode[1].value+',kindInd=2,productEdition=fm.productEdition.value','');changeSubKindCodeCallBack(this);" onchange="getField(this, 'ItemKindSub', '<bean:message key='alert.message.itemkind' />');code_CodeChange(this,'getKindCodeWithIndNew','0,1,2,3,4,8,9','Y','riskCode='+fm.SubGuItemKindRiskCode[1].value+',kindInd=2,productEdition=fm.productEdition.value','');changeSubKindCodeCallBack(this);"> <INPUT name="SubGuItemKindKindName" class="readonly" readonly type="text" style="width:60%" readonly title="<bean:write name='subGuPolicyItemKindDto' property='kindName'/>" value="<bean:write name='subGuItemKindDto' property='kindName'/>"> <input name="SubGuItemKindKindInd" type="hidden" value="<bean:write name='subGuItemKindDto' property='kindInd'/>"> </td> <td class="white"> <input name="SubGuItemKindCalculateInd" class="codecode" type="text" style="width:30%" title="<bean:write name='subGuPolicyItemKindDto' property='calculateInd'/>" value="<bean:write name='subGuItemKindDto' property='calculateInd'/>" ondblclick="getField(this,'ItemKindSub');code_CodeSelect(this,'calculateInd','0,1','Y','02,CalculateInd','setGuItemKindCalculateIndOnchange();');" onkeyup="getField(this,'ItemKindSub');code_CodeSelect(this,'calculateInd','0,1','Y','02,CalculateInd','setGuItemKindCalculateIndOnchange();');" onchange="getField(this,'ItemKindSub');code_CodeChange(this,'calculateInd','0,1','Y','02,CalculateInd','setGuItemKindCalculateIndOnchange();');"> <input name="SubGuItemKindCalculateIndName" class="readonly" type="text" style="width:65%" readonly title="<app:localeName name="subGuPolicyItemKindDto" property="calculateInd,CalculateInd" codeType="ggCodeCodeName" filter="true" />" value="<app:localeName name="subGuItemKindDto" property="calculateInd,CalculateInd" codeType="ggCodeCodeName" filter="true" />"> </td> <td class="white"> <input name="SubGuItemKindSumInsured" class="common01" type="text" style="width: 100%" title="<bean:write name='subGuPolicyItemKindDto' property='sumInsured'/>" value="<bean:write name='subGuItemKindDto' property='sumInsured'/>" onchange="checkSubKindInsured(this);calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','Sub')"> </td> <td class="white"> <input name="SubGuItemKindRate" class="common01" type="text" style="width: 100%" title="<bean:write name='subGuPolicyItemKindDto' property='rate' format="#,##0.000000"/>" value="<bean:write name='subGuItemKindDto' property='rate' format="#,##0.000000"/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','Sub')"> <input name="GuCalculator" type="hidden" value="100"> </td> <td class="white"> <input name="SubGuItemKindShortRateFlag" class="codecode" type="text" style="width: 30%" title="<bean:write name='subGuPolicyItemKindDto' property='shortRateFlag'/>" value="<bean:write name='subGuItemKindDto' property='shortRateFlag'/>" ondblclick="getField(this, 'ItemKindSub', '<bean:message key="alert.message.kindcodeMustInput"/>', '<bean:message key="alert.message.zeroError"/>');code_CodeSelect(this,'shortRateFlag','0,1','Y','02,ShortRateFlag','changeGuItemKindShortRateFlag();');" onkeyup="getField(this, 'ItemKindSub', '<bean:message key="alert.message.kindcodeMustInput"/>', '<bean:message key="alert.message.zeroError"/>');code_CodeSelect(this,'shortRateFlag','0,1','Y','02,ShortRateFlag','changeGuItemKindShortRateFlag();');" onchange="getField(this, 'ItemKindSub', '<bean:message key="alert.message.kindcodeMustInput"/>', '<bean:message key="alert.message.zeroError"/>');code_CodeChange(this,'shortRateFlag','0,1','Y','02,ShortRateFlag','changeGuItemKindShortRateFlag();');"> <input name="SubGuItemKindShortRateFlagName" class="common01" type="text" style="width: 65%" readonly title="<app:localeName name="subGuPolicyItemKindDto" property="shortRateFlag,ShortRateFlag" codeType="ggCodeCodeName" filter="true" />" value="<app:localeName name="subGuItemKindDto" property="shortRateFlag,ShortRateFlag" codeType="ggCodeCodeName" filter="true" />"> </td> <td class="white"> <input name="SubGuItemKindShortRate" type="hidden" value="<bean:write name='subGuItemKindDto' property='shortRate' format="0.00"/>" title="<bean:write name='subGuPolicyItemKindDto' property='shortRate' format="0.00"/>"> <input name="SubGuItemKindShortRateNumerator" class="common01" readonly="readonly" type="text" style="width: 42%" value="<bean:write name='subGuItemKindDto' property='shortRateNumerator' format="#"/>" title="<bean:write name='subGuPolicyItemKindDto' property='shortRateNumerator' format="#"/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','Sub')">/ <input name="SubGuItemKindShortRateDenominator" class="common01" readonly="readonly" type="text" style="width: 42%" value="<bean:write name='subGuItemKindDto' property='shortRateDenominator' format="#"/>" title="<bean:write name='subGuPolicyItemKindDto' property='shortRateDenominator' format="#"/>" onchange="calculatorPremium(this,'<bean:message key="alert.message.kindcodeMustInput"/>','<bean:message key="alert.message.zeroError"/>','Sub')"> </td> <td class="white"> <input name="SubGuItemKindUwPremium" class="readonly" type="text" style="width: 100%" readonly title="<bean:write name='subGuPolicyItemKindDto' property='uwPremium'/>" value="<bean:write name='subGuItemKindDto' property='uwPremium'/>" onchange=" "> <input name="SubGuItemKindOriginUWPremium" class="common01" type="hidden" style="width: 100%" value="<bean:write name='subGuItemKindDto' property='originUWPremium'/>"> </td> <td class="white"> <input name="SubGuItemKindGrossPremium" class="common01" type="text" style="width: 100%" title="<bean:write name='subGuPolicyItemKindDto' property='grossPremium'/>" value="<bean:write name='subGuItemKindDto' property='grossPremium'/>" onchange=""> <input name="SubGuItemKindOriginGrossPremium" class="common01" type="hidden" value="<bean:write name='subGuItemKindDto' property='originGrossPremium'/>"> </td> <td class="white" align="center"> <input name="button_SubKindLimitKind_Edit" class="smallbutton" type="button" style="cursor: hand" value="<bean:message key="button.limit"/>" onclick="showSubPageForPrpall(this,'span_SubKindLimitKind_SubPage');"> <SPAN id="span_SubKindLimitKind_SubPage" name="span_SubKindLimitKind_SubPage" style="display: none; position: absolute; width: 790; background-color: FFFFFF;"> <jsp:include page="/prpall/plugin/common/riskclass/07/itemengineering/SubKindLimitKind.jsp" /> </SPAN> <INPUT name="button_ItemKindSub_Delete" class="smallbutton" type="button" value="<bean:message key="button.delete"/>" ind="ind" onclick="deleteRowInTable(this,'ItemKindSub',1,1);afterEndorDeleteItemKind(this, 'Sub')"> </td> </tr> </logic:notEmpty> <% } } %> </tbody> <tfoot> <TR> <TD class="title02" colspan="9"> <P align="left"><input name="button_ItemKindSub_Insert" class="button" type="button" style="cursor:hand" ind="ind" value="<bean:message key='button.add'/>" onclick="insertRowInTable(this, 'ItemKindSub', 1);"> </P> </TD> </TR> </tfoot> </table> <app:validate formName="ItemEngineeringKindBlockForm" jsFormName="ItemEngineeringKindBlockForm" /> 解析jsp,我想在这段代码 <tfoot> <TR> <TD class="title02" colspan="9"> <P align="left"><input name="button_ItemKindThird_Insert" class="button" type="button" style="cursor:hand" ind="ind" value="<bean:message key='button.add'/>" onclick="insertEngineeringThridItemKind(this, 'ItemKindThird', 1, '<bean:message key='alert.message.aThirdKindOfAItem' />')"> </P> </TD> </TR> </tfoot> 中,使button_ItemKindThird_Insert 这个按钮在endor(批改)时不隐藏,应该怎么增加代码逻辑
最新发布
07-22
<think>好的,我现在需要解决用户的问题:在给定的JSP代码中,如何让button_ItemKindThird_Insert按钮在“endor”(批改)业务类型时不隐藏。首先,我需要理解用户提供的代码结构和当前按钮的显示逻辑。 首先,查看用户提供的JSP代码,特别是按钮所在的部分。按钮的HTML代码是: <input name="button_ItemKindThird_Insert" class="button" type="button" style="cursor:hand" ind="ind" value="<bean:message key='button.add'/>" onclick="insertEngineeringThridItemKind(this, 'ItemKindThird', 1, '<bean:message key='alert.message.aThirdKindOfAItem' />')"> 用户希望这个按钮在“endor”(批改)时不隐藏。通常,在JSP中控制元素显示隐藏的方式有几种:使用CSS的display属性、visibility属性,或者通过Struts的logic标签(如<logic:equal>、<logic:notEqual>)来条件渲染元素。 接下来,需要确定当前业务类型是否为“endor”。在代码中已经有类似的逻辑,例如: <logic:equal parameter="businessType" value="Endor"> ... </logic:equal> 这里使用了Struts的<logic:equal>标签来判断请求参数中的businessType是否为“Endor”(可能大小写需要注意,用户代码中可能是“Endor”或“endor”,需要确认)。假设业务类型通过请求参数或某个作用域中的属性传递,比如parameter="businessType"。 因此,控制按钮显示的逻辑应该基于businessType是否为“Endor”。用户的需求是“在endor时不隐藏”,可能当前按钮在非endor时隐藏,或者默认隐藏,需要在endor时显示。但根据问题描述,用户可能希望无论是否为endor,按钮都显示,或者当前在非endor时隐藏,需要调整条件。 但根据用户的问题,可能当前按钮在某些情况下隐藏,而用户希望在endor时不隐藏。或者可能按钮默认显示,但需要在非endor时隐藏,而用户希望保持在endor时显示。需要明确逻辑。 假设当前按钮在非endor时可能被隐藏,或者用户希望根据businessType来控制显示。例如,可能需要使用<logic:equal>或<logic:notEqual>标签来包裹按钮,根据businessType的值决定是否渲染按钮。 例如,如果当前业务类型是“Endor”,则显示按钮。或者相反。需要看现有代码中的逻辑。例如,在代码其他部分有: <logic:equal parameter="businessType" value="Endor"> ... </logic:equal> 所以,可能的解决方案是使用Struts的logic标签来条件显示按钮。例如,如果用户希望在businessType为“Endor”时显示按钮,则可以用<logic:equal>包裹按钮;如果希望在非Endor时隐藏,而Endor时显示,则同样使用该标签。 但用户的问题是“使button_ItemKindThird_Insert这个按钮在endor(批改)时不隐藏”,可能当前按钮在非endor时是显示的,而在endor时被隐藏,或者相反。需要根据代码上下文判断。但根据常规需求,可能用户希望在endor时按钮仍然可见,可能当前在某些情况下被隐藏,需要添加条件逻辑。 在代码中,按钮所在的位置是<tfoot>中的<tr>,所以可以考虑用<logic:equal>或<logic:notEqual>来包裹按钮的代码,根据businessType的值来决定是否渲染该按钮。 例如,如果当前业务类型是Endor,则显示按钮,否则隐藏。或者反过来。但用户的需求是“在endor时不隐藏”,即无论其他情况,endor时必须显示。可能当前按钮在非endor时显示,而在endor时被隐藏,或者没有控制,用户希望添加控制。 假设当前按钮没有条件控制,用户希望在endor时显示,其他情况可能隐藏或显示。但用户的问题是要在endor时不隐藏,所以可能需要确保在endor时按钮可见。 另一种方法是使用JavaScript根据业务类型动态显示隐藏按钮。例如,在页面加载时检查businessType的值,如果是Endor,则显示按钮,否则隐藏。但JSP中更常见的是使用标签库在服务器端渲染时控制。 在Struts中,可以使用<logic:equal>标签来判断参数或属性的值。例如,假设businessType参数存在,当值为“Endor”时,显示按钮。或者,如果用户希望在endor时不隐藏,即总是显示,可能需要移除隐藏的条件,但根据问题描述,用户可能需要添加条件逻辑来确保在endor时显示。 查看用户提供的代码,发现有其他地方使用了<logic:equal parameter="businessType" value="Endor">,例如: <logic:equal parameter="businessType" value="Endor"> <bean:define name="guItemKindDto" property="guPolicyItemKindDto" id="guPolicyItemKindDto" /> </logic:equal> 这说明businessType参数是存在的,用于判断是否为批改业务。因此,控制按钮的显示可以基于这个参数。 可能的解决方案是使用<logic:notEqual>标签来包裹按钮,当businessType不等于Endor时隐藏,或者使用<logic:equal>来显示。但用户的需求是“在endor时不隐藏”,即endor时显示,其他情况可能隐藏或保持原样。需要明确用户的当前情况。 假设当前按钮在非endor时显示,而在endor时被隐藏,用户希望反转这个逻辑。或者当前按钮没有控制,用户希望在endor时确保显示。 例如,如果希望按钮在endor时显示,可以用: <logic:equal parameter="businessType" value="Endor"> <input ... /> </logic:equal> 但用户的需求是“不隐藏”,可能意味着无论是否为endor都显示,但可能当前在某些情况下隐藏,需要调整。 另一种可能是,按钮默认被隐藏(例如通过CSS),但需要在endor时显示。但根据提供的代码,按钮的style中没有display:none,所以可能不是这种情况。 综合来看,最可能的解决方案是使用Struts的<logic:equal>标签来判断businessType是否为Endor,如果是,则渲染按钮,否则可能不渲染或保持。但用户的需求是“不隐藏”,即endor时显示,所以可能需要确保在endor时按钮被渲染。 或者,可能当前按钮在非endor时被其他逻辑隐藏,用户需要添加条件让endor时不执行隐藏逻辑。但根据提供的代码,按钮的onclick事件是存在的,没有隐藏的样式,所以可能用户希望控制按钮的可见性基于业务类型。 可能的正确做法是在按钮的父元素中使用<logic:equal>或<logic:notEqual>标签,根据businessType的值来决定是否显示按钮。例如,如果用户希望在endor时显示按钮,则: <logic:equal parameter="businessType" value="Endor"> <input name="button_ItemKindThird_Insert" ... /> </logic:equal> 或者,如果希望在非endor时隐藏,而endor时显示,则这样做。但用户的问题是要在endor时不隐藏,可能当前按钮在非endor时隐藏,所以需要反转条件。 或者,可能用户希望按钮始终显示,但在某些情况下被禁用,需要启用。但代码中没有disabled属性,所以可能不是这种情况。 另一种可能是,使用JavaScript在页面加载时根据businessType的值来显示按钮。例如: <script> var businessType = '<%=request.getParameter("businessType")%>'; if (businessType === 'Endor') { document.getElementsByName('button_ItemKindThird_Insert')[0].style.display = 'block'; } else { // 其他情况 } </script> 但JSP中更常见的是使用标签库在服务器端处理。 回到用户提供的代码,按钮所在的位置是: <tfoot> <TR> <TD class="title02" colspan="9"> <P align="left"><input name="button_ItemKindThird_Insert" ...></P> </TD> </TR> </tfoot> 要控制这个按钮的显示,可以用<logic:equal>标签包裹<input>元素,例如: <logic:equal parameter="businessType" value="Endor"> <input name="button_ItemKindThird_Insert" ...> </logic:equal> 或者,如果希望在非Endor时也显示,可能需要检查是否有其他条件导致按钮隐藏,并调整。 但根据用户的问题,可能当前按钮在非Endor时显示,而在Endor时被隐藏,所以需要添加逻辑让Endor时显示。或者用户希望无论何时都显示,但需要确保在Endor时不被隐藏。 另一种可能是,使用<logic:notEmpty>或其他标签,但根据上下文,最可能的解决方案是使用<logic:equal>来判断businessType是否为Endor,并在该条件下显示按钮。 总结,正确的做法是使用Struts的<logic:equal>标签,判断请求参数中的businessType是否为“Endor”(注意大小写可能需要匹配,用户代码中可能是“Endor”),如果是,则渲染该按钮,这样在endor时按钮不会被隐藏。 </think>要让 `button_ItemKindThird_Insert` 按钮在批改(`endor`)业务类型时不隐藏,需要通过条件判断业务类型(`businessType`)并控制按钮的渲染逻辑。以下是具体实现步骤: ### 实现思路 在 JSP 中,通常使用 Struts 的 `<logic:equal>` 标签判断请求参数或作用域属性。已知代码中通过 `parameter="businessType"` 判断业务类型(如 `Endor` 表示批改),因此可以在此按钮的父级元素中添加该标签,确保在 `businessType` 为 `Endor` 时渲染按钮,从而避免隐藏。 ### 修改代码示例 在按钮的 `<input>` 标签外包裹 `<logic:equal>` 标签,判断 `businessType` 是否为 `Endor`(注意大小写需与实际业务参数一致): ```jsp <tfoot> <TR> <TD class="title02" colspan="9"> <P align="left"> <!-- 添加逻辑判断:当业务类型为 Endor 时显示按钮 --> <logic:equal parameter="businessType" value="Endor"> <input name="button_ItemKindThird_Insert" class="button" type="button" style="cursor:hand" ind="ind" value="<bean:message key='button.add'/>" onclick="insertEngineeringThridItemKind(this, 'ItemKindThird', 1, '<bean:message key='alert.message.aThirdKindOfAItem' />')"> </logic:equal> </P> </TD> </TR> </tfoot> ``` 如果需要**无论业务类型是否为 `Endor` 都显示按钮**(即仅确保 `Endor` 时不隐藏),则无需添加条件,直接保留原按钮代码即可。但根据问题描述,可能当前存在隐藏逻辑(如其他条件),因此更合理的方式是显式判断 `businessType` 为 `Endor` 时渲染。 ### 关键说明 - `<logic:equal parameter="businessType" value="Endor">`:通过 `parameter` 属性获取请求参数 `businessType`,若值为 `Endor`(批改),则渲染内部的按钮。 - 若业务类型存储在其他作用域(如 `request`、`session`),需使用 `name` 和 `property` 属性(例如 `<logic:equal name="requestScope" property="businessType" value="Endor">`)。 - 确保 `businessType` 的值与实际业务传递的参数一致(如是否区分大小写,可能为 `endor` 或 `Endor`)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值