<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>4일차</title>

<style>

</style>

<script>

<!-- if  -->

var date = new Date();

var hours = date.getHours();

 

if(hours < 12){

alert('오전입니다');

}

if(hours >= 12){

alert('오후입니다.');

}

<!-- 반복문  -->

var array = ['가', '나', '다', '라'];

array[0] = '윤';

alert(array[0]);

alert(array[1]);

alert(array[2]);

alert(array[3]);

for( var i = 0; i < 4 ; i++){

alert( i + 1 + '번째 출력 : ' + array[i]);

}

<!-- 객체 -->

var product = {

제품명 : '7D 건조 망고',

유형 : '당절임',

성분: '망고, 설탕, 메타중아황산나트륨, 치자황색소',

원산지: '필리핀'

}

for (var i in product){

alert(i+':'+product[i]);

}

<!-- 속성과 메소드 -->

var person = {

name: '홍길동',

eat: function(food){

alert(this.name + '이' + food + '을 먹습니다.');

}

}

person.eat('밥');

</script>

</head>

<body>

</body>

</html>

'Computer > JSP Servlet JavaScript' 카테고리의 다른 글

Eclipse 한글 사용 설정  (0) 2015.01.19
Tomcat 404에러(포트충돌)  (0) 2015.01.16
JSP navigation 마우스오버 Script  (0) 2015.01.14
JSP SQL Injection 방어 기법  (0) 2014.08.21
JSP 버튼이벤트  (0) 2014.08.19

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>3일차</title>

<style>

body{background-color:grey;}

*{color:blue;}

p{text-shadow: 2px 2px 2px; color: green}

.h1class{color: yellow;}

#h1id{color: green;}

h2{color: red;}

ul li{list-style-type: square; color: violet}

.lired{color:red;}

h1{

background:-webkit-linear-gradient(bottom, blue, white);

}

span{background-color:yellow;}

</style>

</head>


<body>

<p>test p tag</p>

<h1>test h1 tag</h1>

<span>span</span>

<span>예제</span>

<ul>

<li class="lired">1인</li>

<li>2인</li>

<li>3인</li>

</ul>

<h1 class="h1class">test h1calss tag</h1>

<h1 id="h1id">test h1id tag</h1>

<h2>other test h2 tag</h2>

</body>

</html>

'Computer > HTML5 CSS3' 카테고리의 다른 글

CSS 초기화 reset.css  (0) 2015.01.16
HTML5 form, input, fieldset, legend 예제  (0) 2015.01.14
HTML5 블로그 만들기 예제  (0) 2015.01.14

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script>

$(document).ready(function () {

$('.outer-menu-item').hover(function () {

$(this).find('.inner-menu').show();

}, function () {

$(this).find('.inner-menu').hide();

});

});

</script>

'Computer > JSP Servlet JavaScript' 카테고리의 다른 글

Tomcat 404에러(포트충돌)  (0) 2015.01.16
JavaScript 예제  (0) 2015.01.15
JSP SQL Injection 방어 기법  (0) 2014.08.21
JSP 버튼이벤트  (0) 2014.08.19
JQUERY 화면전환 없이 비동기 업로드  (0) 2014.08.18

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

</head>


<body>

<nav>

<a href="/html/">HTML</a> |

<a href="/css/">CSS</a> |

<a href="/js/">JavaScript</a> |

<a href="/jquery/">jQuery</a>

</nav>

<h1>This is heading 1</h1>

<h2>This is heading 2</h2>

<h3>This is heading 3</h3>

<h4>This is heading 4</h4>

<h5>This is heading 5</h5>

<h6>This is heading 6</h6>

<mark> 내용</mark>

<p>My mother has 

<span style="color:blue;font-weight:bold">blue</span>

eyes and my father has

<span style="color:darkolivegreen;font-weight:bold">dark green</span>

eyes.</p>

<ul>

<li>Coffee</li>

<li>Tea</li>

<li>Milk</li>

</ul>

<ol>

<li>Coffee</li>

<li>Tea</li>

<li>Milk</li>

</ol>

<ol start="50">

<li>Coffee</li>

<li>Tea</li>

<li>Milk</li>

</ol>

<a href="http://www.w3schools.com" target=“_blank”>Visit W3Schools.com!</a>

<br>

<form>

<fieldset>

<legend>로그인정보</legend>

<ul>

<li>아이디: <input type="text" id="user_id"></li>

<li>비밀번호: <input type="password" id="pw"></li>

</ul>

</fieldset>

<fieldset>

<legend> 가입자정보</legend>

<ul>

<li>이름: <input type="text" id="user_name"></li>

<li>메일주소: <input type="text" id="user_mail"></li>

<li>생년월일: <input type="text" id="birth"></li>

</ul>

</fieldset>

<fieldset>

<input type="submit" value="가입하기"></input>

</fieldset>

</form>

<br>

<form action="demo_form.asp">

<label for="male">Male</label>

<input type="radio" name="sex" id="male" value="male"><br>

<label for="female">Female</label>

<input type="radio" name="sex" id="female" value="female"><br><br>

<input type="submit" value="Submit">

</form>

<br>

<label>주문개수: <input type="number" min="1" max="5" value="1"> 박스(1인당최대5박스)</label><br>

<label>익은정도(3단계) : <input type="range" min ="1" max="3" value="3"></label>

<br>

<label>원하는색상: <input type="color" value=""></label>

<br>

<input type=“month”>

<li>

<label for="pf">사진</label>

<input type="file" name="pf" id="pf">

</li>

</body>

</html>

'Computer > HTML5 CSS3' 카테고리의 다른 글

CSS 초기화 reset.css  (0) 2015.01.16
CSS 글꼴 예제  (0) 2015.01.15
HTML5 블로그 만들기 예제  (0) 2015.01.14

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>MY BLOG</title>

<style>

*{

margin: 0; padding: 0;

font-family: '맑은 고딕', 'Malgun Gothic', Gothic, sans-serif;

}

a {text-decoration: none;}

li {list-style: none;}

body {

width: 960px; margin: 0 auto;

background: #E6E6E6;

}

#page-wrapper{

background: white;

margin: 40px 0; padding: 10px 20px;

border-radius: 5px;

box-shadow: 0 4px 10px rgba(100, 100, 100, 0.3);

}

#main-header{padding: 40px 50px;}

.master-title{

font-size: 23px;

color: #181818;

}

.master-description{

font-size: 15px; font-weight: 500;

color: #383838;

}

#main-navigation{

border-top: 1px solid #C8C8C8;

border-bottom: 1px solid #C8C8C8;

margin-bottom: 20px;

height: 40px;

}

.pull-left{float: left;}

.outer-menu-item{

float: left;

position: relative;

}

.menu-title{

display: block;

height: 30px; line-height: 30px;

text-align: center;

padding: 5px 20px;

}

.outer-menu-item:hover{

background:black;

color: white;

}

.pull-right{float:right;}

.search-bar{

height: 26px;

padding: 7px;

}

.input-search{

display: block;

float: left;

background-color: #FFFFFF;

border: 1px solid #CCCCCC;

border-radius: 15px 0 0 15px;

box-shadow: inset 0 1px 1px rgba(0,0,0,0.05);

width: 120px; height: 24px;

padding: 0 0 0 10px;

font-size: 12px;

color: #555555;

}

.input-search-submit{

display: block;

float: left;

width: 50px; height: 26px;

border-radius: 0 15px 15px 0;

border: 1px solid #CCCCCC;

margin-left: -1px;

vertical-align: top;

display: inline-block;

}

.input-search:focus{

border-color: rgba(82,168,236, 0.8);

outline: 0;

box-shadow: inset 0 1px 1px rgba(0,0,0, 0.05);

}

.inner-menu{

display: none;

position: absolute;

top: 40px; left: 0;

width: 100%;

background: white;

box-shadow: 0 2px 6px rgba(5,5,5, 0.9);

z-index: 1000;

text-align: center;

}

.inner-menu-item > a {

display: block;

padding: 5px 10px;

color: black;

}

.inner-menu-item > a:hover{

background: black;

color: white;

}


#content{

overflow: hidden;

padding: 0 50px;

}

#main-section{

float: left;

width: 510px;

}

#main-aside{

float: right;

width: 200px;

}

article{

padding: 0 10px 20px 10px;

border-bottom: 1px solid #C8C8C8;

}

.article-header{padding: 20px 0;}

.article-title{

font-size: 25px;

font-weight: 500;

padding-bottom: 10px;

}

.article-date{font-size: 13px;}

.article-body{font-size: 14px;}

.aside-list{padding: 10px 0 30px 0;}

.aside-list > h3{

font-size: 15px;

font-weight: 600;

}

.aside-list li a{

margin-left: 8px;

font-size: 13px;

color: #6C6C6C;

}

#main-footer{

padding: 10px 50px;

}

</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script>

$(document).ready(function () {

$('.outer-menu-item').hover(function () {

$(this).find('.inner-menu').show();

}, function () {

$(this).find('.inner-menu').hide();

});

});

</script>

</head>

<body>

<div id="page-wrapper">

<header id="main-header">

<hgroup>

<h1 class="master-title">김민철 BLOG</h1>

<h2 class="master-description">SW A&D</h2>

</hgroup>

<nav id="main-navigation">

<div class="pull-left">

<ul class="outer-menu">

<li class="outer-menu-item">

<span class="menu-title">Introduce</span>

<ul class="inner-menu">

<li class="inner-menu-item"><a href="#">데이터</a></li>

<li class="inner-menu-item"><a href="#">데이터</a></li>

</ul>

</li>

<li class="outer-menu-item">

<span class="menu-title">Interest</span>

</li>

<li class="outer-menu-item">

<span class="menu-title">Best</span>

</li>

</ul>

</div>

<div class="pull-right">

<div class="search-bar">

<form>

<input type="text" class="input-search" />

<input type="submit" class="input-search-submit" value="Search" />

</form>

</div>

</div>

</nav>

</header>

<div id="content">

<section id="main-section">

<article>

<div class="article-header">

<h1 class="article-title">HTML5 개요와활용</h1>

<p class="article-date">2015년01월13일</p>

</div>

<div class="article-body">

<img src="http://placehold.it/430x280" />

<br />

<p>Lorem </p>

<br />

<p>Praesent</p>

</div>

</article>

</section>

<aside id = "main-aside">

<div class="aside-list">

<h3>카테고리</h3>

<ul>

<li><a href="#">데이터</a></li>

<li><a href="#">데이터</a></li>

<li><a href="#">데이터</a></li>

</ul>

</div>

<div class="aside-list">

<h3>최신글</h3>

<ul>

<li><a href="#">데이터</a></li>

<li><a href="#">데이터</a></li>

<li><a href="#">데이터</a></li>

</ul>

</div>

</aside>

</div>

<footer id="main-footer">

<a href="#">Created By MinC</a>

</footer>

</div>

</body>

</html>


'Computer > HTML5 CSS3' 카테고리의 다른 글

CSS 초기화 reset.css  (0) 2015.01.16
CSS 글꼴 예제  (0) 2015.01.15
HTML5 form, input, fieldset, legend 예제  (0) 2015.01.14

SpringMVCMybatis project 이클립스설치->marketplace spring sts

프로젝트 생성  : Spring project MVC

src/main/webapp/web-inf/web.xml 수정 *.do, 인코딩 관련


<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

  <context-param>

    <param-name>contextConfigLocation</param-name>

    <param-value>/WEB-INF/spring/root-context.xml</param-value>

  </context-param>

  <filter>

    <filter-name>encodingFilter</filter-name>

    <filter-class>

       org.springframework.web.filter.CharacterEncodingFilter

   </filter-class>

    <init-param>

      <param-name>encoding</param-name>

      <param-value>utf-8</param-value>

    </init-param>

  </filter>

  <filter-mapping>

    <filter-name>encodingFilter</filter-name>

    <url-pattern>/*</url-pattern>

  </filter-mapping>

  <listener>

    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

  </listener>

  <servlet>

    <servlet-name>appServlet</servlet-name>

    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

    <init-param>

      <param-name>contextConfigLocation</param-name>

      <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>

    </init-param>

    <load-on-startup>1</load-on-startup>

  </servlet>

  <servlet-mapping>

    <servlet-name>appServlet</servlet-name>

    <url-pattern>*.do</url-pattern>

  </servlet-mapping>

</web-app>

pom.xml 수정 DB드라이버 추가 Build path 사용하지않고 추가


<repositories>

<repository>

<id>codelds</id>

<url>https://code.lds.org/nexus/content/groups/main-repo</url>

</repository>

</repositories>

 

 <dependency>
   <groupId>commons-fileupload</groupId>
   <artifactId>commons-fileupload</artifactId>
   <version>1.2.2</version>
  </dependency>
  <dependency>
   <groupId>commons-io</groupId>
   <artifactId>commons-io</artifactId>
   <version>1.3.2</version>
  </dependency>


<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-jdbc</artifactId>

<version>${org.springframework-version}</version>

</dependency>

<dependency>

<groupId>org.mybatis</groupId>

<artifactId>mybatis</artifactId>

<version>3.2.2</version>

</dependency>


<!-- AspectJ -->

<dependency>

<groupId>org.aspectj</groupId>

<artifactId>aspectjweaver</artifactId>

<version>1.6.9</version>

</dependency>

<dependency>

<groupId>org.aspectj</groupId>

<artifactId>aspectjrt</artifactId>

<version>1.6.9</version>

</dependency>


<dependency>

<groupId>cglib</groupId>

<artifactId>cglib</artifactId>

<version>2.2.2</version>

</dependency>



<dependency>

<groupId>org.mybatis</groupId>

<artifactId>mybatis-spring</artifactId>

<version>1.2.0</version>

</dependency>

<dependency>

<groupId>com.oracle</groupId>

<artifactId>ojdbc6</artifactId>

<version>11.2.0.3</version>

<scope>compile</scope>

</dependency>

<dependency>

<groupId>xerces</groupId>

<artifactId>xercesImpl</artifactId>

<version>2.9.1</version>

</dependency>

<dependency>

<groupId>cglib</groupId>

<artifactId>cglib</artifactId>

<version>2.2.2</version>

</dependency>



<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/webapp/web-inf/spring/appservlet/servlet-context.xml 수정

<?xml version="1.0" encoding="UTF-8"?>

<beans:beans xmlns="http://www.springframework.org/schema/mvc"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"

xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd

      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd

      http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd

      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd

      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">


<!-- DispatcherServlet Context: defines this servlet's request-processing 

infrastructure -->


<!-- Enables the Spring MVC @Controller programming model -->

<annotation-driven />

<!-- <context:annotation-config/> -->

<context:component-scan base-package=************************ />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving 

up static resources in the ${webappRoot}/resources directory -->

<resources mapping="/**" location="/resources/" />


<!-- Resolves views selected for rendering by @Controllers to .jsp resources 

in the /WEB-INF/views directory -->

<beans:bean

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

<beans:property name="prefix" value="/WEB-INF/views/" />

<beans:property name="suffix" value=".jsp" />

</beans:bean>




<!-- JNDI기반의 설정 설정 예시 -->

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/myoracle"

resource-ref="true" />

<!-- <beans:bean name="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> 

<beans:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> 

<beans:property name="url" value="jdbc:oracle:thin:@localhost:1521:xe"/> 

<beans:property name="username" value="hr"/> <beans:property name="password" 

value="hr"/> </beans:bean> -->




<beans:bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

<beans:property name="dataSource" ref="dataSource" />

<beans:property name="mapperLocations" value="classpath*:mappers/*Mapper.xml" />

<beans:property name="configLocation" value="classpath:sqlMapConfigure.xml" />


</beans:bean>


<!--공유되지 않고 thread에 안전, requestScope, method scope -->

<beans:bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">

<beans:constructor-arg index="0" ref="sqlSessionFactory" />

</beans:bean>

<tx:annotation-driven transaction-manager="transactionManager" />

<beans:bean id="transactionManager"

class="org.springframework.jdbc.datasource.DataSourceTransactionManager"

p:dataSource-ref="dataSource" />

<tx:advice id="txAdvice" transaction-manager="transactionManager">

<tx:attributes>

<tx:method name="*" propagation="REQUIRED" />

</tx:attributes>

</tx:advice>

<aop:config>

<aop:pointcut expression="within(com.kodb.web.*)" id="serviceInsertMethod" />

<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceInsertMethod" />

</aop:config>

<!-- <beans:bean name="multipartResolver"

class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

<beans:property name="maxUploadSize" value="10000000" />

</beans:bean> -->



</beans:beans>


<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> 서버 설정 server/context.xml JNDI 사용시 서버설정<!--[endif]-->

<Resource name="jdbc/myoracle" auth="Container"

type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"

url="jdbc:oracle:thin:@127.0.0.1:1521:xe"

username="hr" password="hr" maxActive="20" maxIdle="10"

maxWait="-1"/>

 

 

 

src/main/resources/sqlMapConfigure.xml 에 TypeAiases 지정

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE configuration

PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>

<typeAliases>

<typeAlias type="model.MemberVO" alias="membervo/>

</typeAliases>

</configuration>

 

src/main/resources/mappers/memberMapper.xml 생성

<mapper namespace="mymember">

<select id="selectAll" resultType="membervo">

select MNO, EMAIL, PWD, MNAME,

CRE_DATE, MOD_DATE

from members

order by 1

</select>

<select id="selectByNo" parameterType="int" resultType="membervo">

select

MNO, EMAIL, PWD, MNAME, CRE_DATE, MOD_DATE

from members

where MNO = #{mno}

</select>

<update id="updateByNo" parameterType="membervo">

update members

set EMAIL=#{email},

PWD=#{pwd},

MNAME=#{mname},

MOD_DATE = sysdate

where MNO = #{mno}

</update>

<delete id="deleteByNo" parameterType="membervo">

delete from members

where MNO = #{mno}

</delete>

<insert id="insertMember" parameterType="membervo">

insert into

members(MNO, EMAIL, PWD, MNAME, CRE_DATE, MOD_DATE)

values(seq_mno.nextval, #{email}, #{pwd},#{mname},sysdate, sysdate)

<!-- #{cre_date:DATE} -->

</insert>

</mapper>

<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/java/modelVO, DAO(인터페이스사용), Service(인터페이스사용)생성

VO 구현 default생성자+생성자+getter/setter+toString(확인용)

private int mno;

private String email;

private String pwd;

private String mname;

private Date cre_date;

private Date mod_date;

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/java/model/MemberDAO.java 생성 (인터페이스)

public interface MemberDAO {

public ArrayList<MemberVO> selectAll(String condition, String keyword);

public MemberVO selectByNo(int mno);

public MemberVO selectByEmail(String email);

public int insertMember(MemberVO member);

public int updateMember(MemberVO member);

public int deleteMember(int mno);

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/java/model/MemberDAOImpl.java 생성

<!--[if !supportEmptyParas]--> <!--[endif]-->

@Component

public class MemberDAOImpl implements MemberDAO {

@Autowired

SqlSession sqlSession;

<!--[if !supportEmptyParas]--> <!--[endif]-->

public ArrayList<MemberVO> selectAll(String condition, String keyword) {

<!--[if !supportEmptyParas]--> <!--[endif]-->

List list = sqlSession.selectList("mymember.selectAll");

return (ArrayList<MemberVO>) list;

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

@Override

public MemberVO selectByNo(int mno) {

return sqlSession.selectOne("mymember.selectByNo", mno);

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

@Override

public int insertMember(MemberVO member) {

return sqlSession.insert("mymember.insertMember", member);

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

@Override

public int updateMember(MemberVO member) {

return sqlSession.update("mymember.updateByNo", member);

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

@Override

public int deleteMember(int mno) {

return sqlSession.delete("mymember.deleteByNo", mno);

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/java/model/MemberService.java 생성(인터페이스)

public interface MemberService {

public ArrayList<MemberVO> selectAll(String condition, String keyword);

public MemberVO selectByNo(int mno);

public MemberVO selectByEmail(String email);

public int insertMember(MemberVO member);

public int updateMember(MemberVO member);

public int deleteMember(int mno);

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/java/model/MemberServiceImpl.java 생성

@Service

public class MemberServiceImpl implements MemberService{

@Autowired

MemberDAO memberDAO;

@Override

public ArrayList<MemberVO> selectAll(String condition, String keyword) {

return memberDAO.selectAll(condition, keyword);}

@Override

public MemberVO selectByNo(int mno) {

return memberDAO.selectByNo(mno);}

@Override

public MemberVO selectByEmail(String email) {

return memberDAO.selectByEmail(email);}

@Override

public int insertMember(MemberVO member) {

return memberDAO.insertMember(member);}

@Override

public int updateMember(MemberVO member) {

return memberDAO.updateMember(member);}

@Override

public int deleteMember(int mno) {

return memberDAO.deleteMember(mno);}

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/java/controllerMemberController.java 생성

@Controller

public class MemberController {

@Autowired

MemberService memberService;

@RequestMapping("/member/list.do")

public ModelAndView memberlist() {

ModelAndView mv = new ModelAndView();

<!--[if !supportEmptyParas]--> <!--[endif]-->

ArrayList<MemberVO> members = memberService.selectAll(null, null);

mv.addObject("memberlist", members);

mv.setViewName("member/memberlist");

return mv;

}

@RequestMapping(value = "/member/add.do", method = RequestMethod.GET)

public String addMember() {

return "member/memberInsertForm";

}

@RequestMapping(value = "/member/add.do", method = RequestMethod.POST)

public String addMemberPost(MemberVO member) {

int ret = memberService.insertMember(member);

System.out.println(ret + "건 입력됨");

System.out.println(member);

return "redirect:list.do";

}

@RequestMapping(value = "/member/update.do", method = RequestMethod.GET)

public ModelAndView updateMember(int mno) {

MemberVO member = memberService.selectByNo(mno);

ModelAndView mv = new ModelAndView();

mv.addObject("member", member);

mv.setViewName("member/updateForm");

return mv;

}

@RequestMapping(value = "/member/update.do", method = RequestMethod.POST)

public String updateMemberPost(int mno, String email,String pwd, String mname) {

MemberVO member = new MemberVO(mno, email, pwd, mname, null, null);

int ret = memberService.updateMember(member);

System.out.println(ret+"건 수정");

System.out.println(member);

return "redirect:list.do";

}

@RequestMapping("/member/delete.do")

public String deleteMember(int mno) {

ModelAndView mv = new ModelAndView();

int ret = memberService.deleteMember(mno);

System.out.println(ret + "건 수정");

return "redirect:list.do";

}

@ExceptionHandler(Exception.class) //에러발생시 화면전환 + console출력

public String handleException(Exception e){

System.out.println("Eception오류:"+e);

e.getStackTrace();

return "/myerror";

}

}

src/main/webapp/web-inf/views 밑에 auth(login관련)+메인화면+출력화면 jsp파일들 생성

/member/memberlist.jsp

<%@page import="model.MemberVO"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>

<%@ page import="java.util.ArrayList"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<jsp:useBean id="memberlist" class="java.util.ArrayList"

type="ArrayList<MemberVO>" scope="request" />

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

</head>

<body>

<%@include file="../header.jsp"%><br>

<h1>우리반 목록</h1>

<a href='add.do'>신규입력</a><br><br><br>

<%-- <c:if test="${sessionScope.member==null}">

<c:redirect url="../auth/login.do"></c:redirect>

</c:if> --%>

<c:set var="a" value=""></c:set>

<c:set var="b" value=""></c:set>

<c:if test="${condition=='mname'}">

<c:set var="a" value="selected"/>

</c:if>

<c:if test="${condition=='email'}">

<c:set var="b" value="selected"/>

</c:if>

<form action="list.do" method="get">

<select name="condition">

<option value="mname" ${a}>이름

<option value="email" ${b}>이메일

</select>

<input type="text" name="keyword" value="${keyword }">

<input type="submit" value="조회">

</form>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<table border='1'>

<tr>

<th>번호</th>

<th>이름</th>

<th>이메일</th>

<th>암호</th>

<th>가입일</th>

<th>변경일</th>

<th>삭제</th>

</tr>

<c:forEach var="m" items="${memberlist}">

<tr>

<td><a href="update.do?mno=${m.mno }">${m.mno }</a></td>

<td>${m.mname }</td>

<td>${m.email }</td>

<td>${m.pwd }</td>

<td>${m.cre_date }</td>

<td>${m.mod_date }</td>

<td><a href="delete.do?mno=${m.mno }">삭제</a>

</th>

</tr>

</c:forEach>

</table>

<%@include file="../bottom.jsp"%><br>

</body>

</html>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

/member/memberInsertForm.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>

<!--[if !supportEmptyParas]--> <!--[endif]-->

</head>

<body>

<h1>신규등록</h1>

<br>

<br>

<form action="add.do" method="post">

이름 : <input type="text" name="mname"><br> 이메일 : <input

type="text" name="email"><br> 비밀번호 : <input

type="password" name="pwd"><br> <input type="submit"

value="추가"> <input type="reset" value="취소" onclick='func();'>

<!--[if !supportEmptyParas]--> <!--[endif]-->

</form>

</body>

</html>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

/member/updateForm.jsp

<%@page import="model.MemberVO"%>

<%@page import="model.MemberDAO"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!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>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<%-- <%

MemberVO mem = (MemberVO)request.getAttribute("member");

%>

--%>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<h1>회원정보 수정</h1>

<form action="update.do" method="post">

번호:<input type="text" name="mno" value="${member['mno'] }"><br>

이름:<input type="text" name="mname" value="${member.mname }"><br>

이메일:<input type="text" name="email" value="${member.email }"><br>

비밀번호:<input type="text" name="pwd" value="${member.pwd }"><br>

생성일:<input type="text" name="cre_date" value="${member.cre_date }"><br>

수정일:<input type="text" name="mod_date" value="${member.mod_date }"><br>

<input type="submit" value="수정">

<input type="reset" value="취소" >

</form>

<!--[if !supportEmptyParas]--> <!--[endif]-->

</body>

</html>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

에러 발생시 호출되는 페이지

/error.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"

pageEncoding="EUC-KR"%>

<!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=EUC-KR">

<title>Insert title here</title>

</head>

<body>

오류발생~~~~

</body>

</html>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

UpLoad기능추가

pom.xml

<dependency>

<groupId>commons-fileupload</groupId>

<artifactId>commons-fileupload</artifactId>

<version>1.2.2</version>

</dependency>

<dependency>

<groupId>commons-io</groupId>

<artifactId>commons-io</artifactId>

<version>1.3.2</version>

</dependency>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/webapp/upload 폴더 생성

/member/memberInsertForm.jsp

<form action="add.do" method="post" enctype="multipart/form-data">

이름 : <input type="text" name="mname"><br>

이메일 : <input type="text" name="email"><br>

비밀번호 : <input type="password" name="pwd"><br>

사진 : <input type="file" name="file">

<input type="submit" value="추가">

<input type="reset" value="취소" onclick='func();'>

</form>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/java/model/MemberVO 추가 +Getter/Setter

private String fileSrc;

private CommonsMultipartFile file;

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/java/controller/MemberController.javac

if(!member.getFile().isEmpty()){

String path = request.getSession().getServletContext().getRealPath("/upload");

String file = member.getFile().getOriginalFilename();

String fpath = path+"\\"+file;

FileOutputStream fo = null;

System.out.println(fpath);

//나중에 DB에 파일이름 저장하기위함

member.setFileSrc(file);

try {

fo = new FileOutputStream(fpath);

fo.write(member.getFile().getBytes());

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}finally{

try {

if(fo!=null)fo.close();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

src/main/webapp/web-inf/spring/appservlet/servlet-context.xml 수정

<!--[if !supportEmptyParas]--> <!--[endif]-->

<beans:bean name="multipartResolver"

class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

<beans:property name="maxUploadSize" value="10000000" />

</beans:bean>

create or replace procedure sp_employee

is

 cursor cur_emp is

      select first_name, salary

      from employees;

   fname varchar2(20);

   salary number(9,2);

begin

 open cur_emp(id);

 loop

    fetch cur_emp into fname, salary;

    dbms_output.put_line(fname|| '==>' || salary);

    exit when cur_emp%notfound;


 end loop;

 close cur_emp;

end;

/



create or replace procedure sp_employee2

(id in number)

is

 cursor cur_emp(id2 number) is 

      select first_name, salary

      from employees

      where department_id = id2;

   fname varchar2(20);

   salary number(9,2);

begin

 open cur_emp(id);

 loop

    fetch cur_emp into fname, salary;

    dbms_output.put_line(fname|| '==>' || salary);

    exit when cur_emp%notfound;


 end loop;

 close cur_emp;

end;

/



create or replace package pkg_emp

as

 procedure sp_employee;

 procedure sp_employee2(id in number);

end pkg_emp;

/


create or replace package body pkg_emp

as

 procedure sp_employee

 is

    cursor cur_emp is

    select first_name, salary from employees;

    fname varchar2(20);

    salary number(9,2);

 begin

    open cur_emp;

    loop

      fetch cur_emp into fname, salary;

      dbms_output.put_line(fname|| '==>' || salary);

      exit when cur_emp%notfound;

    end loop;

    close cur_emp;

 end sp_employee;


 procedure sp_employee2(id in number)

 is


    cursor cur_emp(id2 number) is 

    select first_name, salary from employees

    where department_id = id2;

    fname varchar2(20);

    salary number(9,2);

 begin

   open cur_emp(id);

   loop

    fetch cur_emp into fname, salary;

    dbms_output.put_line(fname|| '==>' || salary);

    exit when cur_emp%notfound;

    end loop;

 close cur_emp;

 end sp_employee2;


end pkg_emp;

/







'Computer > DB' 카테고리의 다른 글

MySQL 데이터베이스 생성 및 접근권한  (0) 2015.01.21
MySQL 실행 및 관리자 접속  (0) 2015.01.21
SQL 제약조건  (0) 2014.09.01
SQL index, sequnce  (0) 2014.09.01
SQL if  (0) 2014.09.01

create table constraint_emp

(eid char(3) constraint pkeid primary key,

 ename varchar2(20) constraint nename not null,

 eno char(14) constraint neno not null constraint ueno unique,

 email varchar2(25) constraint uemail unique,

 phone varchar2(12),

 hire_date date default sysdate,

 jid varchar2(10) constraint fkjid references jobs(job_id) on delete set null,

 salary number,

 bonus_pct number,

 marriage char(1) default 'n' constraint chk check (marriage in ('y','n')),

 mid number constraint fkmid references emp(empno) on delete set null,

 did number,

constraint fkdid foreign key(did) references dept(deptno) on delete cascade);



select * from user_constraints;

select * from user_cons_columns;



select a.table_name, a.constraint_name, a.constraint_type, 

       b.column_name 

from user_constraints a, user_cons_columns b

where a.owner = 'HR'

and a.table_name = 'EMPLOYEES'

and a.owner = b.owner

and a.constraint_name = b.constraint_name;



insert into constraint_emp (eid, ename, eno,email, hire_date, MARRIAGE)

values ('126', '김민철', '123456786','mckmckmc@kmckmckmc', '09/24/2014', 'y')

select * from constraint_emp




//phone의 길이가 5 이상 되게 제약조건

alter table constraint_emp

add constraint phone_chk

          CHECK ( length(phone) >= 5 )


//salary의 5000 이상 되게 제약조건

alter table constraint_emp

modify constraint salary_chk

          CHECK ( salary >= 5000 )

select * from user_constraints where table_name = 'constraint_emp'


alter table constraint_emp

drop constraint salary_chk


desc constraint_emp




select * from user_constraints;

select * from user_cons_columns;



 


========= 기본키, 외래키에 포함된 칼럼 나태내기 ============


select a.table_name, a.constraint_name, a.constraint_type, 

       b.column_name 

from user_constraints a, user_cons_columns b

where a.owner = 'HR'

and a.table_name = 'EMPLOYEES'

and a.owner = b.owner

and a.constraint_name = b.constraint_name;



'Computer > DB' 카테고리의 다른 글

MySQL 실행 및 관리자 접속  (0) 2015.01.21
SQL cursor  (0) 2014.09.01
SQL index, sequnce  (0) 2014.09.01
SQL if  (0) 2014.09.01
SQL 문자 관련함수  (0) 2014.09.01

select a.index_name, a.table_name,  b.column_name, b.column_position 

from user_indexes a, user_ind_columns b

where a.index_name = b.index_name;



select * from employees

where email like 'SK%'


create index idx_fullname

   on employees (first_name, last_name)


select  first_name, last_name

from employees

where first_name like '%'

and last_name like '%'


select  first_name, last_name

from employees

where first_name like 'Ellen'

and last_name like 'Abel'




//시퀀스

create table board (

 no number primary key,

 title varchar2(20),

 contents varchar2(50) )


drop sequence board_seq

create sequence board_seq

 start with 1

 increment by 1


insert into board

values (board_seq.nextval, '알림', '월요일 반드시 출근')


select * from board


select board_seq.nextval from dual

select board_seq.currval from dual

'Computer > DB' 카테고리의 다른 글

SQL cursor  (0) 2014.09.01
SQL 제약조건  (0) 2014.09.01
SQL if  (0) 2014.09.01
SQL 문자 관련함수  (0) 2014.09.01
SQL nvl union rollup cube  (0) 2014.09.01

declare

  j number := 1;

  k number := 1;

begin

  dbms_output.put_line('------------for test-------------');

 for i in 1..10 loop

  dbms_output.put_line(i);

 end loop;


  dbms_output.put_line('------------loop test-------------');

 loop 

  dbms_output.put_line(j);

  exit when j>=10;

  j := j+1;

 end loop;


  dbms_output.put_line('------------while test-------------');

 while k <= 10 loop

  dbms_output.put_line(k);

  k := k+1;

 end loop;


end;

/







declare

 dno number;

begin

 select deptno

 into dno

 from emp

 where empno =  7844;


 if dno = 10 then

  dbms_output.put_line('내가 가고싶은 부서');

 elsif dno = 20 then

  dbms_output.put_line('가고싶지않아요');

 elsif dno = 30 then

  dbms_output.put_line('놀기');

 else

  dbms_output.put_line('부서배치해주세요');

 end if;


 exception

  when no_data_found then

  dbms_output.put_line('사원이 없어요');

      WHEN   TOO_MANY_ROWS   THEN  

        DBMS_OUTPUT.PUT_LINE('TOO_MANY_ROWS에러 발생');

      WHEN   NO_DATA_FOUND   THEN  

        DBMS_OUTPUT.PUT_LINE('NO_DATA_FOUND에러 발생');

      WHEN OTHERS THEN 

        DBMS_OUTPUT.PUT_LINE('기타 에러 발생');


end;

/

'Computer > DB' 카테고리의 다른 글

SQL 제약조건  (0) 2014.09.01
SQL index, sequnce  (0) 2014.09.01
SQL 문자 관련함수  (0) 2014.09.01
SQL nvl union rollup cube  (0) 2014.09.01
SQL trigger 예제  (0) 2014.09.01

+ Recent posts