JSP파일에서 맨위에 작성
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tld/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/tld/struts-nested.tld" prefix="nested" %>
web.xml에 작성
<taglib>
<taglib-uri>/WEB-INF/tld/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location>
</taglib>
[HTML] 은 taglib 를 사용하지 않은 HTML 소스이고
[taglib] 는 taglib 를 사용한 소스이고
[client] 는 taglib 를 사용한 소스가 웹페이지에서 표현된 결과를 나타낸 것이다.
---------------------------------------------------------------------------------------------------------
FORM TAG
[HTML]
<form name="nontaglibform" action="/non_taglib_form.do" method="post">
</form>
[taglib]
<html:form action="/non_taglib_form">
</html:form>
[client]
<form name="ftaglibform" method="post" action="/non_taglib_form.do">
</form>
---------------------------------------------------------------------------------------------------------
SELECT TAG
[HTML]
<select name="select_value">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
[taglib]
<html:select property="select_value" size="1">
<html:option value="1">1</html:option>
<html:option value="2">2</html:option>
<html:option value="3">3</html:option>
<html:option value="4">4</html:option>
</html:select>
[client]
<select name="select_value" size="1"><option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option></select>
---------------------------------------------------------------------------------------------------------
CHECKBOX TAG
[HTML]
<input type="checkbox" name="chk_value1" value="1" />1
<input type="checkbox" name="chk_value2" value="2" />2
<input type="checkbox" name="chk_value3" value="3" />3
<input type="checkbox" name="chk_value4" value="4" />4
[taglib]
<html:checkbox property="chk_value1" value="true">1</html:checkbox>
<html:checkbox property="chk_value2" value="true">2</html:checkbox>
<html:checkbox property="chk_value3" value="3">3</html:checkbox>
<html:checkbox property="chk_value4" value="4">4</html:checkbox>
[client]
<input type="checkbox" name="chk_value1" value="true">1
<input type="checkbox" name="chk_value2" value="true">2
<input type="checkbox" name="chk_value3" value="3">3
<input type="checkbox" name="chk_value4" value="4">4
---------------------------------------------------------------------------------------------------------
TEXT, HIDDEN TAG
[HTML]
<input type="text" name="text_value" value="">
<input type="hidden" name="hidden_value" value="hidden">
[taglib]
<html:text property="text_value" value="" />
<html:hidden property="hidden_value" value="hidden"/>
[client]
<input type="text" name="text_value" value="">
<input type="hidden" name="hidden_value" value="hidden">
==========================================================================================================
<html>
1. <html:base />
<html:base />
2. <html:button />
<html:button property="itemId">Add</html:button>
3. <html:cancel />
<html:cancel />
4. <html:checkbox />
<html:checkbox property="deleteItem">Delete</html:checkbox>
5. <html:errors />
<html:errors />
6. <html:form />
<html:form action="Search.do" name="searchForm" type="com.wiley.SearchForm" >
</html:form>
7. <html:html />
<html:html>
</html:html>
8. <html:image />
<html:image property="add" src="images/add.gif" />
-> <input type="image" name="add" src="images/add.gif">
9. <html:img />
<html:img page="/images/code.gif" alt="Add to Basket" />
-> <img src="/webappname/add.gif" alt="Add to Basket">
10. <html:link />
<%
String userName = "Bob";
pageContext.setAttribute("userName", userName);
%>
<html:link page="/Edit.do" paramId="user" paramName="userName">Edit User</html:link>
-> <a href="/webappname/Edit.do?user=Bob">Edit User</a>
11. <html:multibox />
<tr>
<td align="left">
Bob
<html:multibox property="nameArray">
Bob
</html:multibox>
</td>
<td align="left">
Robert
<html:multibox property="nameArray">
Robert
</html:multibox>
</td>
<td align="left">
Bobby
<html:multibox property="nameArray">
Bobby
</html:multibox>
</td>
<td align="left">
Roberto
<html:multibox property="nameArray">
Roberto
</html:multibox>
</td>
</tr>
12. <html:select />
<html:select property="userName">
<html:option value="Robert">Robert</html:option>
<html:option value="Bob">Bob</html:option>
<html:option value="Roberto">Roberto</html:option>
<html:option value="Bobby">Bobby</html:option>
</html:select>
13. <html:option />
<html:option value="Robert">Robert</html:option>
14. <html:options />
<%
String users[] = {"Bob", "Robert", "Roberto", "Bobby"};
pageContext.setAttribute("users", users);
%>
<html:form action="select-user.do" method="POST">
<table border="0" width="100%">
<tr>
<td>
<html:select property="userList" size="4" multiple="true">
<html:options name="users" labelName="users" />
</html:select>
</td>
</tr>
</table>
<html:submit>Save</html:submit>
</html:form>
15. <html:password />
<html:password property="password" />
16. <html:radio />
<html:radio property="id" value="100" />
<html:radio property="id" value="200" />
<html:radio property="id" value="300" />
17. <html:reset />
<html:reset>Reset</html:reset>
18. <html:rewrite />
<%
String userName = "Bob";
pageContext.setAttribute("userName", userName);
%>
<html:rewrite page="/Edit.do" paramId="user" paramName="userName" />
-> /struts-exercise-taglib/html-link.do?user=Bob
19. <html:submit />
<html:submit>Submit Query</html:submit>
20. <html:text />
<html:text property="username" />
21. <html:textarea />
<html:textarea property="summary" />
===========================================================================================================
<bean>
1. <bean:cookie />
<bean:cookie id="userId" name="userCookie" value="UNKNOWN_USER" />
2. <bean:define />
<jsp:useBean id="user" scope="page" class="com.wiley.User" />
<bean:define id="name" name="user" property="firstName" />
Welcome: <%= name %>
3. <bean:header />
<bean:header id="headId" name="Cache-Control" value="Cache-Control Not Found" />
4. <bean:include />
<bean:include id="navbar" page="/navbar.jsp" />
5. <bean:message />
<bean:message key="app.title" />
6. <bean:page />
<bean:page id="sessionVar" property="session" />
7. <bean:parameter />
<bean:parameter id="userId" name="username" value="User Not Found" />
8. <bean:size />
<bean:size id="count" name="users" />
9. <bean:struts />
<bean:struts id="userForm" formBean="UserForm" />
10. <bean:write />
<bean:write name="employee" property="username" />
====================================================================================================
<logic>
1. <logic:empty />
<logic:empty name="user">
<forward name="login" />
</logic:empty>
2. <logic:notEmpty />
<logic:notEmpty name="user">
Welcome to our Struts application.
</logic:notEmpty>
3. <logic:equal />
<logic:equal name="user" property="age" value="<%= requiredAge %>">
You are exactly the right age.
</logic:equal>
4. <logic:notEqual />
<logic:notEqual name="user" property="age" value="<%= requiredAge %>">
You are not the right age.
</logic:notEqual>
5. <logic:forward />
* struts-config.xml
<global-forwards>
<forward name="login" path="/login.jsp" />
</global-forwards>
* JSP
<logic:forward name="login" />
6. <logic:redirect />
<logic:redirect name="login" paramId="companyId" paramName="company" />
7. <logic:greaterEqual />
<logic:greaterEqual name="user" property="age" value="<%= minAge %>">
You are old enough.
</logic:greaterEqual>
8. <logic:greaterThan />
<logic:greaterThan name="user" property="age" value="<%= minAge %>">
You are over the minimum age <%= minAge %>.
</logic:greaterThan>
9. <logic:iterate />
<logic:iterate id="employee" name="employees">
<tr align="left">
<td>
<bean:write name="employee" property="username" />
</td>
<td>
<bean:write name="employee" property="name" />
</td>
<td>
<bean:write name="employee" property="phone" />
</td>
</tr>
</logic:iterate>
10. <logic:lessEqual />
<logic:lessEqual name="user" property="age" value="<%= maxAge %>">
You are young enough.
</logic:lessEqual>
11. <logic:lessThan />
<logic:lessThan name="user" property="age" value="<%= maxAge %>">
You are under the maximum age <%= maxAge %>.
</logic:lessThan>
12. <logic:match />
<logic:match name="sentence" value="Bob">
The string Bob occurs in the sentence.
</logic:match>
13. <logic:notMatch />
<logic:notMatch name="sentence" value="Bob">
The string Bob does not occur in the sentence.
</logic:notMatch>
14. <logic:present />
<logic:present parameter="username">
Welcome <%= username %>.
</logic:present>
15. <logic:notPresent />
<logic:notPresent name="username" scope="session">
There is no username attribute in the session.
</logic:notPresent>
====================================================================================================
<template>
1. <template:get />
<%@ taglib uri="/WEB-INF/tlds/struts-template.tld" prefix="template" %>
<html>
<body>
<table>
<tr valign="top">
<td>
<template:get name="navbar" />
</td>
<td>
<table>
<tr><td><template:get name="header" /></td></tr>
<tr><td><template:get name="body" /></td></tr>
<tr><td><template:get name="footer" /></td></tr>
</table>
</td>
</tr>
</table>
</body>
</html>
2. <template:insert />
<%@ taglib uri="/WEB-INF/tlds/struts-template.tld" prefix="template" %>
<template:insert template="/catalogTemplate.jsp">
<template:put name="navbar" content="navbar.jsp" />
<template:put name="header" content="header.jsp" />
<template:put name="body" content="body.jsp" />
<template:put name="footer" content="footer.jsp" />
</template:insert>
3. <template:put />
<template:put name="navbar" content="navbar.jsp" />
===============================================================================================================
<html:text name="boardForm" property="boardValue.name"/>
<input type="text" name=boardValue.name" value="박재성">
'프로그래밍 > struts' 카테고리의 다른 글
struts에서 공통 폼빈(formbean) 및 파일업로드 쓰기 (0) | 2009.06.10 |
---|---|
스트럿츠 validate 사용시 CheckBox 폼 받기 (0) | 2009.06.10 |
struts-config.xml 설명 (1) | 2009.06.10 |
배열 받아오기 및 저장 (iterator) (0) | 2009.06.10 |
html:select (0) | 2009.06.10 |