电子教程倒是下了好几本,都是临到用时去翻。一些基本的东西的概念也是模糊的。像<html:link/>的用法。我就记不得了。书上说:
The html:link tag renders an HTML anchor tag (i.e., a hyperlink). This tag uses a lot of the same common
attributes as described earlier.You have multiple options for rendering the URL of a hyperlink. You can use the
href, action, forward, or page attributes to specify the URL.
The href attribute is used to specify a full
URL without any knowledge of the web context of this web application.
The page attribute is used to specify a
web context relative link.
The action attribute is used to specify a link to an action mapping, as described in the
Struts config file.
The forward attribute is used to specify a link to a global forward, as described in the Struts
config file.
Tip: TIP: If you are following a Model 2/MVC architecture, then you should use the page attribute and
the href attribute sparingly. In fact, you should almost never use the page attribute. The href
attribute should only be used to link to resources that are not in the current web application. This helps
you separate the controller from the View by not letting the View select the next View directly. Only the
controller should select the next View. Using the action and forward attributes instead forces you
to delegate selection of the next View to the controller.
Here is an example of linking to an action (/html-link.do) with the page attribute:
<html:link page="/html-link.do">
Linking with the page attribute.
</html:link>
Notice that you do not have to specify the web context of the web application. Conversely, if you used the href
attribute, you would have to specify the web context as follows (where the context is struts-exercise):
<html:link href="/struts-exercise-taglib/html-link.do">
Using Href
</html:link>
Obviously, it is better to use the page attribute when you are linking to things in the same web application (thus,
the same context). You can also use the href attribute to create links that are not on the same server as follows:
<html:link
href="http://otherserver/strutsTut/html-link.do">
Using Href
</html:link>
Another way to link to the html-link.do action is to use the action attribute as follows:
<html:link action="/html-link">
Using Action attribute
</html:link>