Struts 逻辑 - 希望防止电子邮件确认中出现重复消息
我是 struts 新手,所以请耐心等待。 我想在订单确认电子邮件 jsp 中显示促销消息。我正在从购物车表单的字段中提取此促销代码。它工作正常,只是它会为每个订单行重复消息。如何让它针对给定的促销代码仅打印一次?
<logic:iterate id="orderLineItem name="order" property="orderLines" type"=com.corporation.ecom.OrderLine">
<logic:notEmpty name="orderLineItem" property="promotionCodes">
<logic:iterate id="promo" name="ordeLineItem" property="promotionCodes">
<logic:equal name="promo" value="ABC">
<p>Message goes here...............
</p>
</logicEqual>
<logic:equal name="promo" value="XYZ">
<p>Message goes here...............
</p>
</logicEqual>
</logic:iterate>
</logic:notEmpty>
</logic:iterate>
I'm new to struts so bear with me please.
I want to display a promotional message in the order confirmation email jsp. I'm pulling this promo code from a field on a shopping cart form. It works fine except it duplicates the message for every orderline. How do I get it to print only once for a given promo code?
<logic:iterate id="orderLineItem name="order" property="orderLines" type"=com.corporation.ecom.OrderLine">
<logic:notEmpty name="orderLineItem" property="promotionCodes">
<logic:iterate id="promo" name="ordeLineItem" property="promotionCodes">
<logic:equal name="promo" value="ABC">
<p>Message goes here...............
</p>
</logicEqual>
<logic:equal name="promo" value="XYZ">
<p>Message goes here...............
</p>
</logicEqual>
</logic:iterate>
</logic:notEmpty>
</logic:iterate>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于,我不知道你实际上想做什么。
例如,如果用户输入促销代码,并且它是每个订单的促销代码,但必须与订单项的促销代码匹配,那么您就做错了 - 您需要检查输入的促销对照每个商品的促销代码进行编码,看看是否有匹配的地方。如果有,则打印相应的消息。
在 JSP 中执行此操作是 PITA:我会将其作为 JSP 片段或基于 JSP 的自定义标记来执行。理想情况下,它应该在服务器端完成,这样体积要小得多,并且更容易测试。促销消息的存储位置/方式也有所不同。
It depends, I don't know what you're actually trying to do.
If, for example, the user enters a promo code, and it's a promo-code-per-order, but must match the promo code of a line item, then you're doing it wrong--you need to check the entered promo code against each item's promo code, and see if there's a match anywhere. If there is, then print the appropriate message.
Doing this in the JSP is a PITA: I'd do it as a JSP fragment or as a JSP-based custom tag. Ideally it'd be done on the server side, where it's far less bulky, and way easier to test. Where/how the promo message is stored also makes a difference.