10 reasons and excuses for not using velocity

Source: Internet
Author: User
Tags comments comparison constant
Explain, I use velocity in the project, can say very familiar with.
The article takes this title, just to attract the attention of the gimmick:)

Here are a few questions that confuse me and welcome you to come up with a solution. Thank you.

1. There are too few components available. All pages should be written by themselves. Not to mention the extreme component, which is similar to JSP. The absolute mishap.

2. Inconvenient to use, like JSP, #if, #else flying all over the sky

3. When the JVM's resources are lowered, a normal page condition cannot be generated. The most common is that the picture is not completely displayed. It's hard to see.

4. Constant access is not supported. For example a class of constant someclass.const1, not directly accessible, need to add an ugly getCONST1 () method,
Then add a class declaration in velocity-toolbox.xml (or something like a name file).
The direct result is that almost all of the VMs are magic numbers magicnumber

5. Unlike JSPs, import cannot be supported and can only be referenced in toolbox. The referenced class must be of type static. Use it to miss the JSP in the random new.

6. Need the page to jump automatically when the JSP response.sendredirect ... Very convenient. And the VM needs ... This problem is most commonly encountered when accessing a index.xxx, and the function of an automatic jump is presented. Use JS to jump speed is very slow, so can only ask __ help JSP. (or write a *.do or *.view, and jump with the response in the servlet)

7. Velocity1.4 is different from what 1.5 supports. The former does not support Set,map, if you refer to the official documents, will let people die do not know how to die.
Another 1.4 does not support macro defined in a single VM. If you encounter a complex page that you want to use macro to represent, and this system is part of the integration phase,
It can be cumbersome to not allow changes to the corresponding macro configuration file.

8. The comment will cause a bug. Validation exists in version 1.4. Officially declared # # single-line comments, #* *# Multiple lines of comments, there are bugs.
Single-line bug: such as XXXX (normal code) # # (Comment code) will be problematic.
such as #* ... *# comments, there will be invalid comments, the page will be #* ... Render it together.
I usually <!--#*. *#---so to comment. Helpless Ah.

9. The variables of the page in velocity can only be of type String. So when you want to compare two numbers, you also need a.tostring (). Equals (B.tostring ()). And in the jsp just = = can be. That is, when you encounter a strange error in a VM that encounters an equality comparison of two variables, it is certainly possible to compare them to ToString () and then to equals ().

Is there a difference between the $var and <%= var%>? Why do you think JSP is less than velocity concise?

When the JVM resources are lowered, or the JVM is not getting enough resources, the VM renders abnormally, and the JSP does not. Can you say no to the VM bird thing?

In addition, the VM rendering is not normal, including: CSS display is incorrect, Div is not correct, the picture cannot be displayed.



--------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------

Justification

1. There are too few components available. All pages should be written by themselves. Not to mention the extreme component, which is similar to JSP. The absolute mishap.
This is indeed the case, which is why I chose to freemaker.
sg552 wrote
2. Inconvenient to use, like JSP, #if, #else flying all over the sky
Is there anything else you don't need if else, but you're a jsp,velocity or a freemaker, you need it, whatever the velocity is.
sg552 wrote
3. When the JVM's resources are lowered, a normal page condition cannot be generated. The most common is that the picture is not completely displayed. It's hard to see.
It is difficult to imagine this tube velocity what matter, the picture can not be displayed, even if you use JSP,JVM resources enough, the picture still can't show Ah, two different


5. Unlike JSPs, import cannot be supported and can only be referenced in toolbox. The referenced class must be of type static. Use it to miss the JSP in the random new.
This I remember we discussed, at random in the JSP new is not a good habit, will give refactoring, maintenance and so bring a lot of trouble.


6. Need the page to jump automatically when the JSP response.sendredirect ... Very convenient. And the VM needs ... This problem is most commonly encountered when accessing a index.xxx, and the function of an automatic jump is presented. Use JS to jump speed is very slow, so can only ask __ help JSP. (or write a *.do or *.view, and jump with the response in the servlet)
This is more to say, you can say redirect, A will say JS, basically two different, JSP write Response.sendredirect and servlet write Response.sendredirect is the same, and JS does not border.

9. The variables of the page in velocity can only be of type String. So when you want to compare two numbers, you also need a.tostring (). Equals (B.tostring ()). And in the jsp just = = can be. That is, when you encounter a strange error in a VM that encounters an equality comparison of two variables, it is certainly possible to compare them to ToString () and then to equals ().
You can use #if ("$!{ Number} "= =" 1 "We are using velocity in this way. It's called a convenience. All the page elements are extracted as template
Pagination is also written as a macro. Page elements are also encapsulated. For example <input type= "text" ...../> direct #inputText (name. Value). The page code is simple.
Common components are in one velocitycontext. Any page can be referenced. All operations on the basic types of strings and data are put in context.
You can even put DAO objects into your environment. Refer directly to the page. can have effect to avoid hibernate session closed problem.
In fact, JSP has a good JSP.  Velocity has a good velocity. Look at the situation pull. If there are many pages that are the same common why not use velocity?
And there seems to have been a test. Velocity seems to render faster than a JSP.

is there a difference between the $var and <%= var%>? Why do you think JSP is less than velocity concise?
Let's see how much the two characters are.



The velocity is what we're using now. It's called a convenience. All the page elements are extracted as template
Pagination is also written as a macro. Page elements are also encapsulated. For example <input type= "text" ...../> direct #inputText (name. Value). The page code is simple.
Common components are in one velocitycontext. Any page can be referenced. All operations on the basic types of strings and data are put in context.
You can even put DAO objects into your environment. Refer directly to the page. can have effect to avoid hibernate session closed problem.
In fact, JSP has a good JSP.  Velocity has a good velocity. Look at the situation pull. If there are many pages that are the same common why not use velocity?
And there seems to have been a test. Velocity seems to render faster than a JSP.

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.