Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Thiyagaraja Thamilvaanan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic