Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Panel

The Code

Code Block
html
html
titleWelcome.jsp
borderStylesolidhtml
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
    <title>Welcome</title>
    <link href="<s:url value="/css/tutorial.css"/>" rel="stylesheet"
          type="text/css"/>
</head>
<body>
<h3>Commands</h3>
<ul>
    <li><a href="<s:url action="Register"/>">Register</a></li>
    <li><a href="<s:url action="Logon"/>">Sign On</a></li>
</ul>
</body>
</html>

...

Code Block
html
borderSytlesolid
html
titleHelloWorld.jsphtml
<body>
<h2><s:property value="message"/></h2>

<h3>Languages</h3>
<ul>
    <li>
        <s:url var="url" action="Welcome">
            <s:param name="request_locale">en</s:param>
        </s:url>
        <s:a href="%{url}">English</s:a>
    </li>
    <li>
        <s:url var="url" action="Welcome">
            <s:param name="request_locale">es</s:param>
        </s:url>
        <s:a href="%{url}">Espanol</s:a>
    </li>
</ul>
</body>

...

As we create the application, we will often want to go directly to a page. To make prototyping easy, we can change the Welcome entry to a wilcard mapping.

The Code

Code Block
xml
xml
titlestruts.xml
borderStylesolidxml
<action name="*" >
  <result>/{1}.jsp</result>
</action>

...

Most applications will use several data entry forms. The Struts Tags make creating input forms easy.

Panel

The Code

Code Block
html
html
titleLogon.jsp
borderStylesolidhtml
<%@ 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>

...