숫자, 문자열, 불리언 같은 자료형을 확인할때 


예)

alert( typeof('String') );



alert( typeof(1234) );





'WEB > Javascript 함수' 카테고리의 다른 글

JSON  (0) 2013.04.15
Array  (0) 2013.04.15
내장함수  (0) 2013.04.15
prompt():문자열 입력, confirm(): 불리언 입력  (0) 2013.04.15
문자열관련 함수  (0) 2013.03.27

 

1. 표현식 : 값을 만들어 내는 간단한 코드들

  • 1234
  • 1 + 2 + 3
  • 'abcd'

2. 문장의 끝에는 세미콜론으로 마루리. 

  •  ;

3. 키워드 : 처음 만들때 정해진 특별한 의미가 있는 단어들

break, new, if, true 등 


4. 식별자 

  • 키워드를 사용하면 안된다.
  • 숫자로 시작하면 안된다.
  • 특수문자로 _과 $만 허용한다.
  • 공백문자는 사용할수 없다.


5. 생성관례

  • 생성자함수의 이름은 대문자로 시작
  • 변수,인스턴스,함수,메서드의 이름은 항상 소문자로 시작
  • 여러단어조합인 경우 단어 첫글자는 대문자로 시작


6. 주석

HTML 주석 :  <!--   -->

JAVASCRIPT주석 :  //, /*  */



7. 문자열

  • "ABC" 나 'ABC' 사용가능.
  • 'THIS IS "String"'
  • "THIS IS 'String'"
  • "THIS IS \"String\""  일관대게 "만 사용할 경우 이스케이프 문자 사용. (\")
  •  이스케이프 문자

     
     \t 탭 
     \n

    줄바꿈 

     \'
     \"
     \\

    \\


8. 정수,유리수 구분없이 숫자는 모두 숫자로 표현.


9. Boolean

  • alert( 1 < 2 ); 
    결과값: true
  • boolean끼리 비교 가능 
    true : 1, false: 0 으로 변환되어 비교연산됨.
  • &&(and), ||(or), !(not)



10. 변수

  • var 식별자;
  • 6가지의 자료형 존재.

    var stringVar = 'String';
    var numberVar = 123;
    var booleanVar = true;
    var functionVar = function(){ };
    var objectVar = {} ;
  • undefined 자료형  :  선언하지 않거나 할당하지 않은 변수


str : 문자열

 

 str.length  문자열의 길이 반환
 str.toLowerCase()  소문자로 변환
 str.toUpperCase()  대문자로 변환
 str.charAt(5)  5번째 인덱스에 위치하는 문자 반환
 str.indexOf('e')  해당 문자열의 인덱스(위치)반환
 str.lastIndexOf('e')  해당문자열을 뒤에서부터 검색하여 인덱스(위치)반환
 str.substring(5, 8)  4번째 인덱스에서 8-1번째까지
 str.substr(5, 3)  4번째 인덱스로부터 3자 반환

 

 


 charCodeAt(position)

position에 위치하는 문자의 유니코드 번호를 리턴한다. 

concat(String,...,string) 

매개변수로 입력한 문자열을 이어 리턴한다. 

match(regExp) 

문자열내 regExp가 있는지 확인한다. 

replace(regExp, replacement) 

regExp를 replacement로 바꾼 뒤 리턴한다. 

search(regExp) 

regExp와 일치하는 문자열의 위치를 리턴한다. 

 slice(start,end)

특정위치의 문자열을 추출해서 리턴한다. 

split(separater, limit) 

separator로 문자열을 잘라 배열을 리턴한다. 


'WEB > Javascript 함수' 카테고리의 다른 글

JSON  (0) 2013.04.15
Array  (0) 2013.04.15
내장함수  (0) 2013.04.15
prompt():문자열 입력, confirm(): 불리언 입력  (0) 2013.04.15
typeof 연산자 : 자료형을 확인할때  (0) 2013.04.15

Position>

 

1) absolute

절대적 위치는 엘리먼트가 위치를 잡을때 흐름으로 부터 완전히 제거된다. 그 다음 위치값으로 이동되고, 너비만큼 영역을 잡는다.

두개이상의 엘리먼트가 겹치더라도 다른 엘리먼트에 영향을 주지 않는다.

겹쳐진 두개이상의 엘리먼트는 z-index값으로 조장할수 있다.

 

float를 사용할수 없다.

 

2) relative

absolute는 브라우저의 위치로 부터 시작된다면 relative는 특정 엘리먼트로 부터 위치가 시작된다.

- 로그인 예제

 

- 파일 업로드, 다운로드 예제

 

파일 업로드 관련 라이브러리

\spring-framework-3.0.2.RELEASE-dependencies\org.apache.commons\com.springsource.org.apache.commons.io\1.4.0폴더에서

 

com.springsource.org.apache.commons.fileupload-1.2.0.jar 복사 후 lib에 추가.

 

 

[ 소스경로 ]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(1) 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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>spring06_members</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  <!-- 인코딩필터 설정하기 -->
  <filter>
      <filter-name>characterEncoding</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>characterEncoding</filter-name>
      <url-pattern>/*</url-pattern>
  </filter-mapping>
 
  <!-- /// applicationContext.xml을 읽어와 빈으로 등록하는 리스너 설정 /// -->
  <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>
  <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener> 
 
  <!-- //////////////////// DispatcherServlet설정 //////////////////// -->
 <servlet>
      <servlet-name>mvc</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  </servlet>
  <servlet-mapping>
      <servlet-name>mvc</servlet-name>
      <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <!-- /////////////////////////////////////////////////////////////// -->
 
</web-app>

 

(2) applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <!-- //// 전역적인 자원들이 등록 (Dao,Service,...) ////// -->
   
    <!-- 1. DataSource 설정(url,username,password,..) -->
    <bean id="dataSource" class="org.apache.tomcat.dbcp.dbcp.BasicDataSource"
            destroy-method="close">
        <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
        <property name="username" value="scott"/>
        <property name="password" value="tiger"/>
    </bean>
    <!-- 2. SqlSessionFactory설정(dataSource,Mapper파일설정) -->   
    <bean id="sqlSessionFactory"
                        class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="classpath:test/mybatis/mybatis-config.xml"/>
    </bean>

    <!-- 3. SqlSessionTemplate설정(SqlSessionFactory주입) -->
    <bean id="sqlSessionTemplate"
            class="org.mybatis.spring.SqlSessionTemplate">
        <constructor-arg ref="sqlSessionFactory" index="0"/>   
    </bean>
   
    <!-- 파일 업로드 dao, service설정 -->

    <bean id="fileinfoDao" class="test.dao.FileinfoDao">
        <property name="sqlSessionTemplate" ref="sqlSessionTemplate"></property>
    </bean>
    <!-- service설정 -->
    <bean id="fileinfoService" class="test.service.FileinfoService">
        <property name="dao" ref="fileinfoDao"/>
    </bean>

    <!-- 로그인 dao, service 설정 -->

    <bean id="loginDao" class="test.dao.LoginDao">
        <property name="sqlSessionTemplate" ref="sqlSessionTemplate"></property>
    </bean>
    <!-- service설정 -->
    <bean id="loginService" class="test.service.LoginService">
        <property name="dao" ref="loginDao"/>
    </bean>

</beans>

 

 

(3) mvc-servlet.xml

- multipartResolver : 파일 업로드 관련

- 다운로드 창 설정

- Resolver 에 우선순위를 부여. 우선 순위가 높은 순서로 찾아간다.

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

    <!-- @autowired 만 적용할려면 -->

    <context:annotation-config/>

 

    <bean class="test.controller.FileuploadController"/>
    <bean class="test.controller.FileListController"/>
    <bean class="test.controller.FileDownloadController"/>
    <bean class="test.controller.LoginController"/>
    <bean class="test.controller.FileDeleteController"/>
   
    <!--///////// 파일업로드 관련 시작 //////////////-->
    <!-- id속성이 반드시 multipartResolver 이어야 함. !! -->

    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!-- 최대업로드 크기 설정(바이트단위) -->
        <property name="maxUploadSize" value="5242880"/>
    </bean>

    <!--///////// 파일업로드 관련 끝 //////////////-->
   
   
    <!-- 다운로드 뷰 생성(커스텀뷰) -->

    <bean id="filedownloadView" class="test.view.FiledownloadView"/>

 

    <!--///////// 뷰리절버등록 ///////////-->
    <!-- 뷰이름으로 뷰를 찾아가는 뷰리절버 등록 -->

    <bean class="org.springframework.web.servlet.view.BeanNameViewResolver">
        <property name="order" value="0"/><!-- 리절버중에서 실행순서. 0순위 -->
    </bean>

 

   <bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"></property>
        <property name="order" value="1"/><!-- 리절버중에서 실행순서. 1순위 -->
    </bean>   
</beans>

 

(4) login.jsp

- id, password 체크

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<!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>login.jsp</title>
</head>
<body>
<form action="login.do" method="post">
    아이디<input type="text" name="id"/><form:errors path="command.id"/><br/>
    비밀번호<input type="password" name="pwd"/><form:errors path="command.pwd"/><br/>
    <input type="submit" value="로그인"/>
</form>
</body>
</html>

 

 

 

(5)

(6)

(7)

(8)

(9)

(10)

(11)

(12)

(13)

(14)

(15)

(16)

(17)

(18)

(19)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

'WEB > Spring3.0' 카테고리의 다른 글

SPRING3.0 #12(게시판 annotation사용)  (0) 2013.01.27
SPRING3.0 #11(게시판)  (0) 2013.01.27
SPRING3.0 #11(annotation)  (0) 2013.01.27
SPRING3.0 #10( MVC )  (0) 2013.01.27
SPRING3.0 #09( MVC )  (0) 2013.01.27

+ Recent posts