aspose file tools*
The moose likes Struts and the fly likes Velocity + Struts2 + Sitemesh + Spring +Hibernate Integration How to configur web.xml? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Velocity + Struts2 + Sitemesh + Spring +Hibernate Integration How to configur web.xml?" Watch "Velocity + Struts2 + Sitemesh + Spring +Hibernate Integration How to configur web.xml?" New topic
Author

Velocity + Struts2 + Sitemesh + Spring +Hibernate Integration How to configur web.xml?

Thiyagaraja Thamilvaanan
Greenhorn

Joined: Aug 28, 2009
Posts: 11
Hi friends,

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 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
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Just use the default Velocity result. Note, however, that S2's Velocity support isn't as strong as the FreeMarker support--the error handling in FreeMarker is much stronger.

Someone else will have to chime in about SiteMesh, I've used it only rarely.

Spring support is strong via the Struts 2 Spring plugin.
Thiyagaraja Thamilvaanan
Greenhorn

Joined: Aug 28, 2009
Posts: 11
David Newton wrote:Just use the default Velocity result. Note, however, that S2's Velocity support isn't as strong as the FreeMarker support--the error handling in FreeMarker is much stronger.

Someone else will have to chime in about SiteMesh, I've used it only rarely.

Spring support is strong via the Struts 2 Spring plugin.



Thanks David,
I got some good ideas from your reply.

and this also helped me a lot.

http://struts.apache.org/2.0.6/docs/sitemesh-plugin.html
Thiyagaraja Thamilvaanan
Greenhorn

Joined: Aug 28, 2009
Posts: 11
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Velocity + Struts2 + Sitemesh + Spring +Hibernate Integration How to configur web.xml?