I T C o t e n s P r o v i d e r h t t p : / / w w w. h a n b i t b o o k. c o. k r
I T C o t e n s P r o v i d e r h t t p : / / w w w. h a n b i t b o o k. c o. k r
Jakarta is a Project of the Apache Software Foundation, charged with the creation and maintenance of commercial-quality, open-source, server-side solutions for the Java Platform, based on software licensed to the Foundation, for distribution at no charge to the public. from Jakarta.apache.org
Struts encourages application architectures based on the Model 2 approach, a variation of the classic Model-View-Controller(MVC) design paradigm. Struts provides its own Controller component and integrates with other technologies to provide the Model and the View. For the Model, Struts can interact with any standard data access technology, including Enterprise Java Beans, JDBC, and Object Relational Bridge. For the View, Struts works well with JavaServer Pages, Velocity Templates, XSLT, and other presentation Systems. from Struts Home
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> <web-app> <!-- Action Servlet Configuration --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.actionservlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/web-inf/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>2</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet>
<!-- Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- Application Tag Library Descriptor --> <taglib> <taglib-uri>/web-inf/app.tld</taglib-uri> <taglib-location>/web-inf/app.tld</taglib-location> </taglib> <!-- Struts Tag Library Descriptors --> <taglib> <taglib-uri>/web-inf/struts-bean.tld</taglib-uri> <taglib-location>/web-inf/struts-bean.tld</tagliblocation> </taglib> <taglib> <taglib-uri>/web-inf/struts-html.tld</taglib-uri> <taglib-location>/web-inf/struts-html.tld</tagliblocation> </taglib> <taglib> <taglib-uri>/web-inf/struts-logic.tld</taglib-uri> <taglib-location>/web-inf/struts-logic.tld</tagliblocation> </taglib> </web-app>
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd"> <struts-config> <form-beans> <form-bean name="inputform" type="com.hanbit.struts.inputform"/> </form-beans> <action-mappings> <action path="/input" type="com.hanbit.struts.inputaction" name="inputform" scope="request" input="/input.jsp"> <forward name="output" path="/output.jsp" /> </action> </action-mappings> </struts-config>
<%@ page contenttype="text/html; charset=euc-kr" %> <html> <body> <form method="post" action="input.do"> : <input type="text" name="name"> <br><br> : <select name="address"> <option value=" "> </option> <option value=" "> </option> <option value=" "> </option> <option value=" "> </option> </select> <br><br> [ web.xml ] <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action. ActionServlet</servlet-class> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> [ struts-config.xml ] <action path="/input" type="com.hanbit.struts.inputaction" name="inputform" scope="request" input="/input.jsp"> <forward name="output" path="/output.jsp" /> </action>
: <input type="checkbox" name="hobby" value=" "> <input type="checkbox" name="hobby" value=" "> <input type="checkbox" name="hobby" value=" "> <input type="checkbox" name="hobby" value=" "> <br><br> : <input type="radio" name="gender" value=" "> <input type="radio" name="gender" value=" "> <br><br> <input type=submit value=" "> </form> </body> </html>
package com.hanbit.struts; import org.apache.struts.action.actionform; public class InputForm extends ActionForm { private String name ; private String address ; private String[] hobby ; private String gender ; //name public void setname(string name) {this.name = engtokor(name);} public String getname() {return name;} //address public void setaddress(string address) {this.address = engtokor(address);} public String getaddress() {return address;} //hobby public void sethobby(string[] hobby) {this.hobby = engtokor(hobby);} public String[] gethobby() {return hobby;} //gender public void setgender(string gender) {this.gender = engtokor(gender);} public String getgender() {return gender;}
//Encoding String Type English To Korean public String engtokor(string str) { if(str == null str.trim().equals("")) return str; try { return new String(str.getBytes("ISO-8859-1"), "EUC-KR"); }catch(java.io.unsupportedencodingexception uee) { return null; } } } //Encoding Array Type English To Korean public String[] engtokor(string[] str) { if(str.length == 0) return str; for(int i=0; i<str.length; i++) { try{ str[i] = new String(str[i].getBytes("ISO-8859-1"), "EUC-KR"); }catch(java.io.unsupportedencodingexception uee) { return null; } } return str; }
package com.hanbit.struts; import org.apache.struts.action.*; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.servletexception; import java.io.ioexception; public class InputAction extends Action { } public ActionForward perform(actionmapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { } return mapping.findforward("output"); <action path="/input" type="com.hanbit.struts.inputaction" name="inputform" scope="request" input="/input.jsp"> <forward name="output" path="/output.jsp" /> </action>