Simplifying the Spring (4) View layer

Source: Internet
Author: User
Tags bind extend

Similarly, freemarker and velocity enthusiasts skip this article. As with the reason to discard the webwork and use the Spring MVC controller interface alone, Freemarker is a good thing, but also supports the taglib of JSP across the boundary, and gets the full support of WebWork, but for its non-standard, The number of users and the lack of IDE, in the view layer we still use a conservative but everyone will use, IDE-friendly JSP2.0 with Jstl.

For the B/s structure of the enterprise application software, the basic page is no more than two kinds, one is filled form, one is the DataGrid data list management, and then with some CSS, JS, Ajax effect, is the view layer to pay attention to things.

1. JSP 2.0 el Replacement <c:out>

JSP2.0 can write El directly in the HTML section, without having to use <c:out> node, to be honest, the page effect that Jsp2.0+jstl achieves is no more than velocity difference. <p>{goods.name}</p>

Replace

<p><c:out value= "{goods.name}"/></p>

(in addition to the El inside can not call goods functions, sun that old stubborn always insist jstl only for data display, not data operations, so can not call the Bean's Get/set method)

2. The laziest form data binding

Spring few of the few tags are basically chicken ribs, completely can not. The simple Form tag in spring development has not yet been released. Spring's tag is mainly used to bind the value of VO to the input box. However, like struts, you need to bind each input box, and the syntax is extremely verbose, and you have to deal with the Select box yourself ... A typical Spring sample page makes people dizzy.

And Jodd's form tag gives us lazy people a lazy way, as long as the <form> at both ends with <jodd:form bean= "Myvo" ></jodd:form> wrapped, inside all the input boxes, Select box, checkbox ... All automatically bound, such a simple thing, really do not understand why not struts,spring, for unnecessary flexibility?

<form>
<jodd:form bean="human">
<input type="text" name="name">
<input type="radiobox" name="sex" value="man">
<select name="age">
 <option value="20">20</option>
 <option value="30">30</option>
</select>
</jodd:form>
</form>

However, Jodd has a fatal weakness that cannot bind the values of inline objects. For example, there is a customer (customer) object in the Order object, and jodd cannot be bound like struts,spring with the following syntax:

<input name= "Customer.customerno" >

This is because it's beanutils than Jakata common weak, with a wrong way of thinking. Use Beanutils to modify it, the revised source code can be downloaded.

3. DataGrid Data List

Displaytag and ValueList all belong to this form of tag Library. But the recent emergence of extreme table is the real killer, he is powerful not to say, and from the beginning to think about how to allow others to extend the overload, such as extend attributes mechanism is displaytag so that the thousand people side will not reserve.

4.css, JavaScript, Ajax

The world is troubled, there is nothing special want to say to recommend, love who it. Buffalo, DWR, scriptaculous, Prototype, Ajaxtags, Ajaxanywhere, Rico, Dojo, JSON-RPC, look at the name on the headache.

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.