728x90
반응형

jquery.datetimepicker.full.min.js
0.06MB
jquery.datetimepicker.min.css
0.02MB

 

jQuery의 datetimepicker를 이용하면 날짜 선택시 시작일과 종료일 선택 시, 시작일이 종료일보다 뒤로 선택되거나 반대로 종료일이 시작일보다 빠른 날짜로 선택되는 것을 방지할 수 있습니다.

 

위에 첨부한 두 파일을 다운로드해서 사용해주세요.

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- datetimepicker 스타일 적용 -->
    <link rel="stylesheet" href="jquery.datetimepicker.min.css">
    <title>Document</title>
</head>

<body>
    
    <div>
        시작일자 <input type="text" id="startDate" autocomplete="off">
    </div>
    
    <div>
        종료일자 <input type="text" id="endDate" autocomplete="off">
    </div>

</body>


<!-- 제이쿼리 import -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>


<!-- datetimepicker import -->
<script type="text/javascript"
        src="jquery.datetimepicker.full.min.js"></script>

<script type="text/javascript">

    $(document).ready(function() {
        fn_egov_init_date()
    })

    function fn_egov_init_date(){
        var $startDate = $('#startDate');
        var $endDate = $('#endDate');
        $startDate.datetimepicker({
            timepicker: false,
            lang: 'ko',
            format: 'Y-m-d',
            scrollMonth: false,
            scrollInput: false,
            onShow: function (ct) {
                this.setOptions({
                    maxDate: $endDate.val() ? $endDate.val() : false
                })
            },
        });

        $endDate.datetimepicker({
            timepicker: false,
            lang: 'ko',
            format: 'Y-m-d',
            scrollMonth: false,
            scrollInput: false,
            onShow: function (ct) {
                this.setOptions({
                    minDate: $startDate.val() ? $startDate.val() : false
                })
            }
        });

    }
</script>
</html>
728x90
반응형

대전 거주자 위주로 일본어 회화 과외합니다.

 

보유 일본어 자격증 : JLPT N2, BJT 490점, JPT 815점

 

일본 거주 경험 : 오사카 워킹홀리데이, 도쿄경제대학교 교환유학

 

 

도쿄경제대에서 1년 교환 유학하며 일본인 대학생들 대상으로 한국어 회화를 가르친 경험이 있습니다.

 

자격증 위주가 아닌 회화 교육이라면 자신 있습니다.

 

교환유학, 워킹홀리데이, 일본 취업을 앞두신 분 중에서 일본어 회화 공부하고 싶으신 분 연락주세요.

 

 

Zoom으로 온라인 강의도 가능합니다.

728x90
반응형

웹 개발을 파비콘 이미지가 지정되어 있지 않을 때 생기는 오류입니다.

 

가장 좋은 방법은 파비콘 이미지를 넣어주는 것이지만 이미지가 없다면 아래 코드를 삽입하여 에러를 없앨 수 있습니다.

 

<link rel="icon" href="data:;base64,iVBORw0KGgo=">
728x90
반응형

build.gradle에 의존성 추가

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.security:spring-security-test'
}

 

ORM 기술로 JPA, 보안을 위한 스프링 시큐리티, View 템플릿 타임리프와 롬복, MariaDB 등을 추가했습니다.

 

Config 패키지 생성 후 Sring Security 관리 클래스 생성

package com.sh.springsec.config;

import com.sh.springsec.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

@RequiredArgsConstructor
@EnableWebSecurity
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    private final UserService userService;

    @Override
    public void configure(WebSecurity web) {
        web.ignoring().antMatchers("/css/**", "/js/**", "/img/**");
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .antMatchers("/login", "/signup", "/user").permitAll()
                .antMatchers("/").hasRole("USER")
                .antMatchers("/admin").hasRole("ADMIN")
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .loginPage("/login") // 로그인 페이지 링크
                .defaultSuccessUrl("/") // 로그인 성공 후 리다이렉트 주소
                .and()
                .logout()
                .logoutSuccessUrl("/login") // 로그아웃 성공시 리다이렉트 주소
                .invalidateHttpSession(true); // 세션 날리기
    }

    @Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userService).passwordEncoder(new BCryptPasswordEncoder());
    }
}

 

Spring Security를 사용하기 위해 WebSecurityConfigurerAdater를 상속받은 Security Config 클래스를 만들었습니다. Spring Security 사용을 위해서는 @EnableWebSecurity 어노테이션을 달아줘야 합니다. 위에서 오버라이딩한 메소드는 configure 메소드는 각각 WebSecurity, HttpSecurity와 AuthenticationManagerBuilder를 매개변수로 받습니다.

 

메소드 역할

public void configure(WebSecurity web) {

    web.ignoring().antMatchers("/css/**", "/js/**", "/img/**");

}

 

스프링 시큐리티 인증 없이도 접근 가능하게 할 경로를 설정합니다.

 

protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
        .antMatchers("/login", "/signup", "/user").permitAll()
        .antMatchers("/").hasRole("USER")
        .antMatchers("/admin").hasRole("ADMIN")
        .anyRequest().authenticated()
        .and()
        .formLogin()
        .loginPage("/login")
        .defaultSuccessUrl("/")
        .and()
        .logout()
        .logoutSuccessUrl("/login")
        .invalidateHttpSession(true);
}

 

권한에 따라 접근할 수 있는 경로를 지정합니다.

 

메소드 역할
.authorizeRequests() 시큐리티 처리에 HttpServletRequest를 사용
.antMatchers(String) 특정 경로를 지정
.hasRole(String) 지정된 경로에 특정 권한을 가진 사용자만 접근 가능
.permitAll() 지정된 경로에 모든 사용자가 접근 가능
.anyRequest() 위에서 지정되지 않은 경로
.authenticated() 권한을 갖지 않은 사용자를 로그인 페이지로 리다이렉트
.formLogin() 커스텀 로그인 페이지에 관한 설정
.loginPage(String) 로그인 페이지 지정
.defaultSuccessUrl(String) 로그인 성공 시 리다이렉트 할 페이지 지정
.logout() 로그아웃 설정
.logoutSuccessUrl(String) 로그아웃 성공 시 리다이렉트 할 페이지 지정
.invalidateHttpSession(boolean) 로그아웃 후 사용자 권한과 세션의 제거 여부 설정

 

+ Recent posts