Simplified spring (4)-view layer

Source: Internet
Author: User
Author: Jiangnan Baiyi

Life is like a stage. Please let us go.
Similarly, freemarker and velocity fans should skip this article. Freemarker is just as good as abandoning webwork and using the spring MVC Controller Interface. It also supports JSP taglib across borders and is fully supported by webwork, but for its non-standardization, the number of users and the lack of IDE, we still use in the view layerConservative but usable by everyone. ide-friendly jsp2.0 works with jstl.

For enterprise application software with B/S structure, there are two basic types of pages, one is to fill in form, the other is to manage the DataGrid data list, and then with some CSS, the effect of JS and Ajax is what the view layer should pay attention.

1. Replace El of JSP 2.0 with <C: Out>
Jsp2.0 can directly write El in the HTML part without using the <C: Out> node. To be honest, the page effects of jsp2.0 + jstl are no different from those of velocity.

<P> {goods. name} </P>
Replace
<P> <C: Out value = "{goods. name}"/> </P>

(Except El, goods functions cannot be called. Sun insisted that jstl can only be used for data display and cannot perform data operations. Therefore, bean get/set methods cannot be called)

 2. the lazy form data binding

Spring has few poor tags, which are basically chicken ribs. The spring tag is mainly used to bind the VO value to the input box. However, like struts, You need to bind input boxes one by one, and the syntax is extremely lengthy. When you encounter a select box, you have to handle it yourself... the typical spring Sample Page makes people feel dizzy.

The form tag of jodd gives us a method that we are too lazy to use. We only need to use <jodd: Form bean = "myvo"> </jodd: Form> to wrap it at <form>, all input boxes, select boxes, checkbox... all of them are automatically bound. I really don't understand why struts and spring don't need such a simple task. Is it necessary 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, a fatal weakness of jodd is that it cannot bind values of embedded objects. For example, if the order object contains a customer object, jodd cannot be bound with the following syntax like struts and spring:

 

<Input name = "customer. customerno">

This is because its beanutils is weaker than jakata common and uses a wrong idea. Use beanutils to modify the source code. You can download the modified source code here.

3. DataGrid data list

Both displaytag and ValueList belong to the tag library in this form. However, the recent extreme table is a real killer. It has powerful functions and has been thinking about how to let others perform expansion and overloading from the very beginning, for example, the extend attributes mechanism is displaytag, which makes it not reserved for everyone.

4. CSS, JavaScript, Ajax
There is nothing special about the recommended products. Buffalo, DWR, scriptaculous, prototype, ajaxtags, ajaxanywhere, Rico, dojo, JSON-RPC, looked at the name of a headache.

Related Articles
Simplified spring (1) -- configuration file
Simplified spring (2) -- model layer
Simplified spring (3) -- controller Layer
Simplified spring (4) -- View Layer

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.