4, view
There are several techniques as a view that can be used:
l JSP: This is a well-known technology that Java web developers can be used as a general choice; this tutorial introduces the use of Webwork in JSP
l Velocity: A Java-based template engine, providing simple and powerful template language VTL to replace JSP, separating Java code from the web page
l FreeMaker: For MVC mode design, another JAVA-based template engine that can replace JSP, but compatible with JSP tags
4.1, use JSP as a view
With JSP rendering views, you can use Scriptlets or WebWork tags to access data of the action. It is recommended to use the WebWork tag library.
(1) Access the ACITION data using Scriptlets
In ScriptleTs, you are using the Value Stack object to access the Action data. Below is the result output page of the second example in the previous section using the ScriptleTs:
<% @ Page Import = "com.opensymphony.xwork.util.ognlvaluestack"%>
hEAD>
<%
Ognwateck Stack = (OgnwaStack) Request.GetaTribute ("Webwork.Valuestack");
Out.write ("Hello," Stack.FindValue ("Person");
%>
body>
html>
However, it is recommended to use the WebWork tag, as in the second example in the last section, with a clear grammar, and can be processed when the Value Stack object does not exist.
(2) Use the WebWork tag library
The WebWork tag library can be divided into 7 categories:
l General Mark: The most common basic marker;
l Component Tag: Generate a component in the view;
l Process Control Tag: Controlling the process in JSP;
l Iteration tag: Traverse access element or operation can be traversed objects;
l UI tag: Generate an HTML form field and control;
l VUI tag: (requires volunteers to write);
l Internationalized marks: makes views international;
(1) Universal tag
Get the result attribute value; if the value does not exist, return the top value in the Value Stack
Push value into Value Stack
Set the parameter (attribute) value of the parent tag; the tag can only be used inside other tags
Sets the object value of the value of the specified range (Page, Stack, Application, Session) in the Value Stack; if no value is specified, use the top value in the Value Stack
Create an encoded URL
(2) Component marker
Perform an action in the context of Taglib, the marker is used to display the response result of the action.
Create a JavaBean in ActionContext, instantize its properties so that you can use it later.
Contains another page or action
(3) Process control marker
If the condition tagged Boolean expression is true, the contents of the standard
If the Boolean expression of the previous condition is false, the contents of the computing mark
If the front condition tag is false, the Boolean expression of this condition is TRUE, the content of the calculation mark
(4) Iteration tag
Traverse a collection
Generate traversal objects
Add traversal objects
Get a subset of traversal objects
Merge several traversal objects are one.
(5) UI tag
Generating the UI tag for the HTML form control and the WebWork core is designed to minimize the number of compilation code logic and use the template system to present the representative of HTML. The UI marker covers most common tags, and provides a component tag to create a custom component. The UI tag also provides built-in support to display intact error message. Detailed introduction to the UI tag, is described in the next section.
(6) VUI tag
Volunteers are needed to write.
(7) Internationalization markers
Print international string
Place a resource into the Value Stack so that