Stripes MVC 模型数据
我对 Spring MVC 有经验,正在尝试 Stripes 来决定是否在新项目中尝试它。
在 Spring MVC 中,我将准备模型数据并将其传递到视图,方法是将其添加到控制器创建的 ModelAndView 实例中的映射中。我很难找到与 Stripes 相同的内容。
似乎最接近的相似之处是让 ActionBean 准备我的模型数据并将其添加到 HttpSession。 ForwardRedirect 用于加载视图并从会话访问数据。
Stripes 是否对前端控制器提供了更好的支持,或者这是与 Spring MVC 完全不同的设计原理? (即我必须使用 EL 从视图中调用方法来检索数据,正如某些示例所做的那样)
谢谢!
I am experienced with Spring MVC and am trying out Stripes to decide whether to try it out for a new project.
In Spring MVC I would prepare model data and pass it to the view by adding it to a map in the ModelAndView instance created by my controller. I am having trouble finding the equivalent of this for Stripes.
It seems like the closest parallel is to have an ActionBean prepare my model data and add it to the HttpSession. A ForwardRedirect is used to load the view and the data is accessed from the session.
Is there better support for a front controller provided by Stripes, or is this a totally different design principle than Spring MVC? (ie I have to invoke methods from the view using EL to retrieve data, as some of the examples do)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Stripes 中的典型 MVC 设计类似于下面的代码。
JPA 实体由 Stripersist 提供的 Stripes 拦截器自动加载(但是这也可以轻松地自己实现 如果你愿意的话)。因此,在此示例中,请求 http://your.app/show-order-12.html 将从数据库加载 id 为 12 的订单并将其显示在页面上。
控制器 (OrderAction.java):
视图 (order.jsp):强>
模型(Order.java):
顺便说一句,有一本关于 Stripes 的非常优秀的短书(!),涵盖了所有这些内容:
Stripes:...Java Web 开发再次变得有趣
A typical MVC design in Stripes would look like something like the code below.
The JPA entity is automaticaly loaded by a Stripes interceptor provided by Stripersist (but this can also easily implemented on your own if you wish). Thus in this example, requesting http://your.app/show-order-12.html will load a order with id 12 from the database and will show it on the page.
Controller (OrderAction.java):
View (order.jsp):
Model (Order.java):
BTW there is an really excellent short(!) book on Stripes that covers all these things:
Stripes: ...and Java Web Development Is Fun Again
好吧,我已经弄清楚了。 页面中可用
添加到 HttpServletRequest(从上下文中检索)的属性在接收 ForwardRedirect IE 的
context.getRequest().setAttribute("attr1", "请求属性1");
返回新的 ForwardResolution("/WEB-INF/pages/hello.jsp");
在 hello.jsp 中
${attr1}
可用...耶!
Okay I have figured it out. Attributes added to the HttpServletRequest (retrieved from context) ARE available in the page receiving the ForwardRedirect
IE
context.getRequest().setAttribute("attr1", "request attribute 1");
return new ForwardResolution("/WEB-INF/pages/hello.jsp");
In hello.jsp
${attr1}
is available... yay!
nopCommerce 3.20 (MVC) 有一个很好的解决方案。它是一个支付插件,支持授权、授权/捕获、退款和部分退款。包括 PCI 合规性,数据库上不存储 CC 信息
http://shop.wama-net.com/en/stripe - payment-plugin-for-nopcommerce
Jacky
There is on one nice solution for nopCommerce 3.20 (MVC). It's a payment plugin supporting, authorize, authorize/capture, refund and partially refund. PCI compliance included, no CC info is stored on db
http://shop.wama-net.com/en/stripe-payment-plugin-for-nopcommerce
Jacky