Struts2
provide form tag, to create HTML forms. You can create forms like following.
<s:form>
</s:form>
For
formEx.jsp s:form tag interpreted like below.
<form
id="formEx" name="formEx"
action="/struts_tutorial/formEx.jsp"
method="post">
<table
class="wwFormTable">
</table>
</form>
Just like
adding text fields, password fields, textareas and other HTML UI components to
HTML form tag, you can add UI components to struts form tag.
For example,
following snippet creates simple login form.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <s:form> <s:textfield name="userName" label="user name : " /> <s:password name="password" label="password : " /> <s:submit /> </s:form> </body> </html>
<form id="formEx" name="formEx" action="/struts_tutorial/formEx.jsp" method="post"> <table class="wwFormTable"> <tr> <td class="tdLabel"><label for="formEx_userName" class="label">user name : :</label></td> <td><input type="text" name="userName" value="" id="formEx_userName" /></td> </tr> <tr> <td class="tdLabel"><label for="formEx_password" class="label">password : :</label></td> <td><input type="password" name="password" id="formEx_password" /></td> </tr> <tr> <td colspan="2"><div align="right"> <input type="submit" id="formEx_0" value="Submit" /> </div></td> </tr> </table> </form>
No comments:
Post a Comment