软件架构:如何抽象 Portlet API
我们正在使用 Spring MVC,我们希望构建一个可以作为 Portlet 运行的应用程序,也可以作为常规 WebApp 运行相同的代码库。
我们愿意牺牲一些 Portlet 功能并满足于一组通用的功能。
是否有 API 或技术可以实现这一目标?
We are using Spring MVC and we would like to build an Application that could run as a Portlet AND as a regulard WebApp the same code base.
We are willing to sacrifice some of the Portlet features and settle for a common set of Features.
Is there an API or Technique to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 Spring 2.5 或 3.0,您可以考虑使用它们的 @Controller 注释,这些注释就是为了这个目的,而不是扩展 Spring 的 AbstractController 类(这些类特定于您试图摆脱的 Servlet 或 Portlet 规范)。
查看 http:// /static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/portlet.html#portlet-annotation
@RequestMapping 注释可能会配置不同的值,我认为这取决于您使用的是 Servlet 还是 Portlet 规范...因此,如果您仍然遇到任何障碍,您可能会考虑使用一个 Java 类来实现所有基本逻辑并具有一些最小的外观注释控制器,一个用于 Servlet,一个用于 Portlet,只需将其委托给您的一个核心逻辑类。
If you are using Spring 2.5 or 3.0, you can look into using their @Controller annotations which are for this very purpose rather than extending Spring's AbstractController classes (which are specific to the Servlet or Portlet spec that you are trying to get away from).
Check out http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/portlet.html#portlet-annotation
The @RequestMapping annotations may configured with different values I think depending on if you're using Servlet or Portlet spec... so if you still run into any snags you might look into having a Java class that implements all your basic logic and having some minimal facade annotated controllers, one for Servlet and one for Portlet, that simply delegate off to your one core logic class.