速度 + Struts2 + Sitemesh + Spring +Hibernate 集成 如何配置 web.xml?
我需要创建一个应用程序,使用 Struts2 作为 MVC,使用 Hibernate 进行数据访问,并在业务逻辑中使用 Spring。 我还需要使用 Velocity 进行演示,使用 sitemesh 进行模板化。
集成 Hibernate 和 Spring 很容易,但将 spring、sitemesh 和 Velocity 与 Struts2 集成在一起 我不清楚,但我可以在 Struts2 中单独使用速度、弹簧和 sitemsh。
当然,如本示例所示 http://www.rkcole.com/articles /struts/crudTutorial/step4.html sitemesh和spring可以与struts2集成,配置web.xml为
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
现在我的任务是将velocity与这个组合集成............
通常要集成Velocity和struts2我使用以下
<servlet-class>
org.apache.velocity.tools.view.servlet.VelocityViewServlet
</servlet-class>
<load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>velocity</servlet-name>
<url-pattern>*.vm</url-pattern>
</servlet-mapping>
.. ...................................................... .........................................
现在我的问题是如何设置`
<servlet-mapping>
` ,它仅适用于速度,或 simemesh 或必须进行不同的设置,
请让我知道如何继续,如果可以,请回复完整的 web.xml 和其他要遵循的步骤。
问候
T.Thamilvaanan
I needed to create an application using Struts2 as MVC,Hibernate for data access and spring in the business logic.
And also I needed to use Velocity for presentaion and sitemesh for templating.
Integrating Hibernate and Spring is done easily but integrating spring, sitemesh and velocity together with Struts2
is not clear for me but I can use velocity,spring and sitemsh individually with Struts2.
Of course as illustrated in this example http://www.rkcole.com/articles/struts/crudTutorial/step4.html
sitemesh and spring can be integrated with struts2 configuring web.xml as
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
Now my task is to integrate velocity with this combination...............
Normally to integrate Velocity and struts2 I use the following
<servlet-class>
org.apache.velocity.tools.view.servlet.VelocityViewServlet
</servlet-class>
<load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>velocity</servlet-name>
<url-pattern>*.vm</url-pattern>
</servlet-mapping>
.............................................................................................
Now my question is how to set `
<servlet-mapping>
`, its only for velocity, or simemesh or has to be set differently
Please let me know how to proceed,if can please reply with complete web.xml and others steps to be followed.
Regards
T.Thamilvaanan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,经过大量阅读和搜索,我终于得到了这个 web.xml......
希望这很好,将测试并让你知道。
干杯............
问候
Thamilvaanan
Ya, finally I got this web.xml after lots of reading and searching............
Hope this is fine,will test and let you know.
Cheers............
Regards
Thamilvaanan