20220315 º¹½À

< ¼­ºí¸´ >
     Web > java > ¼­ºí¸´
     java °´Ã¼ÁöÇâ 80%
     useBean ¾×¼Ç > ¼­ºí¸´

-GET ¹æ½Ä
     URL µÚ¿¡ "?" ¸¶Å©¸¦ ÅëÇØ URLÀÇ ³¡À» ¾Ë¸².
     ? µÚ¿¡ name=jgc&age=20 µîÀÇ key=value Çü½ÄÀ¸·Î µ¥ÀÌÅ͸¦ º¸³½´Ù.

-POST¹æ½Ä
     URL µÚ¿¡ ºÙ¿©¼­ º¸³»Áö ¾Ê°í,
     ÇìµåÇʵå·Î µ¥ÀÌÅÍŸÀÔÀ» ¸í½ÃÇÑ ÈÄ,
     BODY¿¡ µ¥ÀÌÅ͸¦ ³Ö¾î¼­ º¸³½´Ù.


ÁÖ¼Ò·Ï ¸¸µé±â ( address_book )_ctl = ab_ctl

MVC > Model + View + Controller
MVC Áß ControllerÀÇ ±â´É°ú Á߿伺¿¡ ÁÖ¸ñ!

ab_ctl?command=list, update, register ...
ab_list
ab_update
ab_delete

DAO ( Data Access Object ) = DB¶û ¿¬°áµÊ ( ¼ºÀûó¸®ÇÁ·Î±×·¥ÀÇ ScoreManager )
AddrBean Ŭ·¡½º
void connect()
void disconnect()
boolean insertDB();
boolean updateDB();
boolean deleteDB();
boolean getDB();
boolean selectDB();

DO ( Data Object ) = ( ¼ºÀûó¸®ÇÁ·Î±×·¥ÀÇ ScoreData )
AddrBook Ŭ·¡½º
ab_id;
ab_name;
ab_email;
ab_tel;
ab_birth;
ab_comdepth;
ab_memo;

CREATE TABLE IF NOT EXISTS `lego` (
`idx` int(10) NOT NULL AUTO_INCREMENT,
`ab_id` varchar(20) NOT NULL COMMENT 'ÁּҷϹøÈ£',
`ab_name` varchar(20) NOT NULL COMMENT 'À̸§',
`ab_email` varchar(50) NOT NULL COMMENT 'À̸ÞÀÏ',
`ab_tel` varchar(50) NOT NULL COMMENT 'ÀüÈ­¹øÈ£',
`ab_birth` varchar(10) NOT NULL COMMENT '»ýÀÏ',
`ab_comdepth` int(10) NOT NULL DEFAULT '0' COMMENT '´ñ±Û±íÀÌ',
`ab_memo` varchar(50) NOT NULL COMMENT '¸Þ¸ð',
`reg_date` datetime NOT NULL COMMENT 'µî·ÏÀÏ',
PRIMARY KEY (`idx`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='ÁÖ¼Ò·Ï';


example - ab_ctl.jsp

< %@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR" % >
< !DOCTYPE html >
< html >
< head >
< meta charset="EUC-KR" >
< title >53±â ÁÖ¼Ò·Ï< /title >
< /head >
< body >
< %
     String command=request.getParameter("command");
     //out.println(command+"< br >");
     if( command.equals("select") ){
          //out.println("ÁÖ¼Ò·Ï Ãâ·Â< br >");
          response.sendRedirect("ab_list.jsp");
     }else if(command.equals("insert")){
          response.sendRedirect("ab_form.html");
     }else if(command.equals("update")){
          out.println("ÁÖ¼Ò·Ï ¼öÁ¤< br >");
     }else if(command.equals("delete")){
          out.println("ÁÖ¼Ò·Ï »èÁ¦< br >");
     }else{
          out.println("¿À·ù ó¸®< br >");
     }
% >
< a href="/0315_9/ab_ctl.jsp?command=select">¸ñ·Ï< /a> |
< a href="/0315_9/ab_ctl.jsp?command=insert">µî·Ï< /a> |
< a href="/0315_9/ab_ctl.jsp?command=update">¼öÁ¤< /a> |
< a href="/0315_9/ab_ctl.jsp?command=delete">»èÁ¦< /a> |

< /body >
< /html >