Using Struts2 Tags (IV)

18 January 2008

Please go through all the parts of Using Struts2 Tabs before going through this one.

struts.xml

<action name="*" >
  <result>/tutorial/{1}.jsp</result>
</action>

Explanation:

If no other mapping matches, the framework will match “Start” to the asterisk, and substitute “Start” for any “{1}” tokens in the mapping.

Likewise, if there is a link to a “Login” action, and nothing else matches, then the “/Login.jsp” page is returned instead.
Note: Wildcard mappings let you create your own conventions, so that you can avoid redundant configuration. The first mapping that matches a request wins.

Creating Data Entry Forms

Almost all the applications will use data entry forms, the Struts2 Tags make it easy.

Logon.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
  <title>Login</title>
</head>
<body>
<s:form action="Logon"> 
  <s:textfield label="User Name" name="username"/>
  <s:password label="Password" name="password" />
  <s:submit/>
</s:form>
</body>
</html>

Explanation:

The JSP engine reads the taglib reference at the top of the page and loads the Struts Tags for use with this page under the prefix “s”. The Struts Tags textfield, password, and submit each emit the appropriate label and control type, so you dont have to specify separate lables elements.

del.icio.us:Using Struts2 Tags (IV)  digg:Using Struts2 Tags (IV)  spurl:Using Struts2 Tags (IV)  wists:Using Struts2 Tags (IV)  simpy:Using Struts2 Tags (IV)  newsvine:Using Struts2 Tags (IV)  blinklist:Using Struts2 Tags (IV)  furl:Using Struts2 Tags (IV)  reddit:Using Struts2 Tags (IV)  fark:Using Struts2 Tags (IV)  blogmarks:Using Struts2 Tags (IV)  Y!:Using Struts2 Tags (IV)  smarking:Using Struts2 Tags (IV)  magnolia:Using Struts2 Tags (IV)  segnalo:Using Struts2 Tags (IV)  gifttagging:Using Struts2 Tags (IV)

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Using Struts2 Tags (IV)

Leave a Reply