How to Use Struts Layout

Struts-layout is a tag library of helpful layout commands included in the Struts framework. When a struts-layout web application is accessed, the struts-layout tags automatically generate the necessary HTML and formats it from an external cascading style sheet file. Struts-layout simplifies the creation of common form items and organizes data displays by using simple HTML-like tags.

Instructions

    • 1

      Create a new JSP page in a text editor or development application. Save the file into your project directory

    • 2

      Type "<%@ page language="java" %><%@ taglib uri="/WEB-INF/struts-layout.tld" prefix="layout" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>". This is the standard header for a struts-layout JSP page. It declares the scripting language as Java and imports the necessary struts-html and struts-layout libraries.

    • 3

      Type "<layout:html>". This tag begins the layout declaration for creating HTML and is a required tag.

    • 4

      Type "<layout:form action="myAction">" to open a new form. Forms contain input methods that collect and process data from the user. "myAction" refers to a user-defined script that will process the input data. A login prompt with username, password and a submit button is a common example of a form.

    • 5

      Use the "<layout:text>," "<layout:password>," "<layout:date>" and the other form input tags to provide functionality to the web application. Each input option has individual properties that can be customized based on your project's needs. For example, typing "isRequired="true"" in a field declaration will place a red star next to it to signify its importance and require the field be completed before submitting.

    • 6

      Type "<layout:submit property="submit" value = "submit" />" to create a standard submit button. The submit button causes the form to process the input data and is a vital aspect of a form. A cancel button can also be created by using the "<layout:cancel>" tag. The "<layout:reset />" tag creates a button to clear all data in the input form.

    • 7

      Use the "<layout:row>" and "<layout:column>" tags to set up rows and columns similar to table structures in HTML. Rows contain a number of columns for easy distribution of information across a space. The size of the rows and columns can be set using the height and width properties.

Tips & Warnings

  • All the tags in struts-layout must be closed adding a closing tag. A closing tag is the name of the tag with a "/" in front of it. For example, the "<layout:html>" tag is closed with "</layout:html>." The closing order is based on the hierarchy of the elements.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值