简体   繁体   English

如何在Struts1 framewok中添加Struts2

[英]How to add Struts2 in Struts1 framewok

I have product which is build on Struts1 framework, instead of moving the full framework to latest Struts2, I want to start with new feature with Struts2 framework. 我有基于Struts1框架构建的产品,而不是将整个框架移至最新的Struts2,而是要从Struts2框架的新功能入手。

On looking on multiple sites, I learned that we can have both Struts1 and Struts2 framework running together. 通过查看多个站点,我了解到我们可以同时运行Struts1和Struts2框架。 So while trying to do that, I have added the entry for filter class of Struts2 in web.xml 因此,在尝试执行此操作时,我在web.xml中添加了Struts2过滤器类的条目

<filter>
  <filter-name>struts2</filter-name>
  <filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  </filter-class>
</filter>

And also the filter mapping to /*.action . 还有过滤器映射到/*.action

Now when comes to adding action, in Struts1 the struts-config tag is used, whereas in Struts2 it is just struts. 现在要添加动作时,在Struts1中使用struts-config标记,而在Struts2中仅使用struts。

How should I handle both version in common struts.xml file. 我应该如何在通用的struts.xml文件中处理两个版本。

While you can have both struts1 and 2 in one application, you can't mix and match the configuration. 虽然您可以在一个应用程序中同时使用struts1和2,但是您不能混合和匹配配置。

You will need to keep configuring your struts1 actions (.do) like you have done before and start configuring the struts2 actions (.action) in the struts2 way. 您将需要像以前一样继续配置struts1动作(.do),并开始以struts2方式配置struts2动作(.action)。

They actually live side by side. 他们实际上并肩生活。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM