Mysql.java
LoginAction.java
RegMember.java
struts.xml
package dao; public class Mysql { public void insert(String id){ System.out.println("커넥션 연결됨"); System.out.println(id+" 회원 가입 처리되었습니다"); } }
package Service; public class LoginAction { public String execute(){ System.out.println("로그인 처리중"); System.out.println("id 비번 모두 일치함 통과"); return "success"; } }
package Service; import dao.Mysql; public class RegMember { String id; public String getId() { //jsp에서 ${id} return "id :"+ id+""; } public void setId(String id) { System.out.println("RegMember-setId="+id); this.id = id; } public String execute(){ System.out.println("RegMember-execute"); new Mysql().insert(id); //db에 회원가입 요청 return "success"; } }
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.i18n.encoding" value="UTF-8" /> <constant name="struts.devMode" value="true" /> <package name="hi" extends="struts-default" namespace="/" > <action name="RegMember" class="Service.RegMember" > <interceptor-ref name="params" /> <result type="chain"> <param name="actionName">LoginAction</param> <param name="namespace">/</param> </result> </action> <action name="LoginAction" class="Service.LoginAction" > <interceptor-ref name="chain"></interceptor-ref> <interceptor-ref name="params"></interceptor-ref> <result>/Success.jsp</result> </action> </package> </struts>web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>04.validate</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>Form.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!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> 회원가입페이지 <form action="RegMember.action" > <input text="text" name="id" size="8"> <input type="submit" value="보내기"> </form> </body> </html>Success.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!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> 회원가입 성공 ${id} </body> </html>
'Struts2 > 2012.04월 강좌(MySQL)' 카테고리의 다른 글
4일차 Exception, Logging , Profiling (0) | 2012.06.08 |
---|---|
4일차 단일 파일 업로드, 다중 파일 업로드 (0) | 2012.06.08 |
3일차 Struts Standard Tag Library (0) | 2012.06.08 |
3일차 validate() (0) | 2012.06.07 |
2일차 interface 활용하기 (0) | 2012.06.05 |