• 둜그인
  • μž₯λ°”κ΅¬λ‹ˆμ— μƒν’ˆμ΄ μ—†μŠ΅λ‹ˆλ‹€.

home2 κ²Œμ‹œνŒ Spring κ²Œμ‹œνŒ Thymeleaf λŒ€μ‹  pug μ“°κΈ°

Thymeleaf λŒ€μ‹  pug μ“°κΈ°

  • 이 μ£Όμ œμ—λŠ” 1개 λ‹΅λ³€, 2λͺ… μ°Έμ—¬κ°€ 있으며 codingappleκ°€ 1 λ…„, 8 μ›” 전에 전에 λ§ˆμ§€λ§‰μœΌλ‘œ μ—…λ°μ΄νŠΈν–ˆμŠ΅λ‹ˆλ‹€.
2 κΈ€ λ³΄μž„ - 1 μ—μ„œ 2 κΉŒμ§€ (총 2 μ€‘μ—μ„œ)
  • 글쓴이
    κΈ€
  • #130481

    κΉ€μ§€ν•œ
    μ°Έκ°€μž
    Springμ—μ„œ ꢌμž₯ν•˜λŠ” Thymeleafλ₯Ό μ“°λŠ”κ²Œ μ·¨μ—…μ—λŠ” 쒋을지 λͺ°λΌλ„ , μ €λŠ” μž¬λ―Έκ°€ μš°μ„ μ΄λΌμ„œ γ…‹γ…‹γ…‹
    pug 둜 μ„ΈνŒ…ν•˜λŠ” 방법을 μ•Œμ•„λ‚΄μ„œ 잘 μ‚¬μš©μ€‘μž…λ‹ˆλ‹€.
    νƒ€μž„λ¦¬ν”„λ³΄λ‹€ νŽΈλ¦¬ν•œ 점이 λ§Žμ€λ°
    예λ₯Ό λ“€μ–΄
    nav파일 ν¬ν•¨ν•˜λŠ”κ±° include nav.pug ν•˜λ©΄ 끝, κ°„κ²°ν•œ 문법이 μ’‹μ•„μ„œ μ“°κ³ μžˆμ–΄μš”.
    ----------
    body
        include nav.pug
        h4 λ©”μΈνŽ˜μ΄μ§€
    ---------
    Pugκ°€ κ΄„ν˜Έκ°€ 적고 파이썬 μŠ€νƒ€μΌμ˜ λ“€μ—¬μ“°κΈ°λ‘œ μœ„κ³„λ₯Ό νŒŒμ•…ν•˜λŠ”κ±°λΌ, νŒŒμ΄μ¬μ„ μ’‹μ•„ν•˜λ©΄
    금방 μ΅μˆ™ν•΄μ§ˆκ²ƒκ°™μ•„μš”.
    ν˜Ήμ‹œ κ΄€μ‹¬μžˆμœΌμ‹  뢄은 ν•œλ²ˆ ν•΄λ³΄μ„Έμš”.
     
    μ„ΈνŒ…λ²•
    ----------------------
    build.gradle
    dependencies {
        // Pug
        implementation 'de.neuland-bfi:spring-pug4j:3.2.0'
    }
    ---------------------
    μœ„μ˜κ²ƒ μΆ”κ°€ν•˜μ‹œκ³ 
    com.apple.shop μ•„λž˜μ— Config 폴더 λ§Œλ“€μ–΄μ„œ
    PugConfigλΌλŠ” 클래슀λ₯Ό λ§Œλ“€κ³ 
    -----------------------
    package com.apple.shop.Config;
    import de.neuland.pug4j.PugConfiguration;
    import de.neuland.pug4j.spring.template.SpringTemplateLoader;
    import de.neuland.pug4j.spring.view.PugViewResolver;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    @Configuration
    public class PugConfig {
      @Bean
      public SpringTemplateLoader templateLoader() {
        SpringTemplateLoader templateLoader = new SpringTemplateLoader();
        templateLoader.setTemplateLoaderPath("classpath:/templates");
        templateLoader.setEncoding("UTF-8");
        templateLoader.setSuffix(".pug");
        return templateLoader;
      }
      @Bean
      public PugConfiguration pugConfiguration() {
        PugConfiguration configuration = new PugConfiguration();
        configuration.setCaching(false);
        configuration.setTemplateLoader(templateLoader());
        return configuration;
      }
      @Bean
      public PugViewResolver viewResolver() {
        PugViewResolver viewResolver = new PugViewResolver();
        viewResolver.setConfiguration(pugConfiguration());
        return viewResolver;
      }
    }
    ----------------------------
    μ΄λ ‡κ²Œ νŒŒμΌν•˜λ‚˜ λ§Œλ“€λ©΄ λ˜λ”κ΅°μš”.
    컨트둀러 ν΄λž˜μŠ€μ—μ„œλŠ”
    -----------------------
    @GetMapping("/")
    String index() { 
    return "index";
    }
    -------------------
    indexλ‹€μŒμ— ν™•μž₯자 μ•ˆλΆ™μ΄λ©΄ pugνŒŒμΌμ„ λ Œλ”λ§ ν•΄μ€λ‹ˆλ‹Ή.
    • 이 κ²Œμ‹œκΈ€μ€ κΉ€μ§€ν•œμ— μ˜ν•΄ 1 λ…„, 8 μ›” 전에 μˆ˜μ •λμŠ΅λ‹ˆλ‹€.
    • 이 κ²Œμ‹œκΈ€μ€ κΉ€μ§€ν•œμ— μ˜ν•΄ 1 λ…„, 8 μ›” 전에 μˆ˜μ •λμŠ΅λ‹ˆλ‹€.
    • 이 κ²Œμ‹œκΈ€μ€ κΉ€μ§€ν•œμ— μ˜ν•΄ 1 λ…„, 8 μ›” 전에 μˆ˜μ •λμŠ΅λ‹ˆλ‹€.
    • 이 κ²Œμ‹œκΈ€μ€ κΉ€μ§€ν•œμ— μ˜ν•΄ 1 λ…„, 8 μ›” 전에 μˆ˜μ •λμŠ΅λ‹ˆλ‹€.
    • 이 κ²Œμ‹œκΈ€μ€ κΉ€μ§€ν•œμ— μ˜ν•΄ 1 λ…„, 8 μ›” 전에 μˆ˜μ •λμŠ΅λ‹ˆλ‹€.
    #130492

    codingapple
    ν‚€ λ§ˆμŠ€ν„°
    κ°œμΆ”
2 κΈ€ λ³΄μž„ - 1 μ—μ„œ 2 κΉŒμ§€ (총 2 μ€‘μ—μ„œ)
  • 닡변은 둜그인 ν›„ κ°€λŠ₯ν•©λ‹ˆλ‹€.

About

ν˜„μž¬ μ›” 700λͺ… μ‹ κ·œμˆ˜κ°•μ€‘μž…λ‹ˆλ‹€.

  (09:00~20:00) λΉ λ₯Έ 상담은 카톑 ν”ŒλŸ¬μŠ€μΉœκ΅¬ μ½”λ”©μ• ν”Œ (링크)
  admin@codingapple.com
  μ΄μš©μ•½κ΄€, κ°œμΈμ •λ³΄μ²˜λ¦¬λ°©μΉ¨
β“’ Codingapple, κ°•μ˜ 예제, μ˜μƒ 볡제 κΈˆμ§€
top

Β© Codingapple, All rights reserved. μŠˆνΌλ‘œμΌ“ μ—λ“€μΌ€μ΄μ…˜ / μ„œμšΈνŠΉλ³„μ‹œ 강동ꡬ κ³ λ•λ‘œ 19κΈΈ 30 / μ‚¬μ—…μžλ“±λ‘λ²ˆν˜Έ: 212-26-14752 온라인 κ΅μœ‘ν•™μ›μ—… / ν†΅μ‹ νŒλ§€μ—…μ‹ κ³ : 제 2017-μ„œμšΈκ°•λ™-0002 호 / κ°œμΈμ •λ³΄κ΄€λ¦¬μž: 박쒅흠 / λŒ€ν‘œμžλͺ…: λ°•ν•΄μœ€