There are two ways to integrate struts2 with velocity

Source: Internet
Author: User

1. ToStruts2 mainly.Struts2 built-in support for velocity, as long as the <result name= "success"? type= "Velocity" >success.vm</result> You can automatically parse the velocity template file.
Issue: When accessing VM files directly, the source code of the VM is output. How do I prohibit direct access to *.VM type files?
Benefits: You can use similarStruts tab. I always feel that this is a strange use.

2, with velocity as the main. Configuring the Velocity servlet and *.VM mappings in Web. xml
Benefit: Very convenient to use velocity tools2.0 (need to add several Jar class libraries)

Because you do not want to use the struts label, regardless of 1 and 2, the client cannot generate the same JavaScript code as the server-side validation , Validatortool only applies to struts1.1, which has not been updated for two years.
Solution: Use jquery or MooTools form to validate the collection and write part of the code. When it comes to Ajax, it also requires handwriting, and integration is too complex to save

According to the above, the individual thinks that the best of the scheme 2, direct *.VM map out, simple and convenient. There is no need to use the struts Tag Library.

Just thought of the question: Can the VM automatically generate HTML files to use Apache Direct output, secondary access no longer need to go through the program?
VMs are efficient, cached template technology that has a higher output performance than a jsp. The purpose of static is to use Web servers such as Apache to mitigate the stress of application servers such as Tomcat

Static is not very useful, if the traffic is large, increase the throughput of the hardware service area and use Squid server-side cache (this is also static), or to solve the problem from the architecture

There are two ways to integrate struts2 with velocity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.