2016-10-06 17 views
0

템플릿으로 thymeleaf를 사용하여 스프링 부트 응용 프로그램을 개발했습니다. 내 application.properties에서 server context-path를 사용합니다. 내 views.html에 이미지를 표시해야하는 경우CSS의 서버 컨텍스트 경로 및 이미지 URL

server.context-path: /myapp/v1.0 

나는

<img th:src="@{/img/first.png}" /> 

모든 것이

멋진 구문을 사용하지만 '내 CSS 파일을 이미지를 dosn 사용해야하는 경우에 일

/* Search input */ 
input.search-input { 
    text-align: left; 
    background-image: url('/img/search.png'); 
} 

당신은 어떤 생각이 있니? 답은 상대 경로를 사용하여 이미지를 참조해야 CSS 파일에서

답변

0

에 대한

감사합니다. 폴더 구조 (src/main/resources부터)과 같은 경우

:

. 
├── application.properties 
├── static 
│   ├── css 
│   │   └── style.css 
│   └── img 
│    └── first.png 
└── templates 
    └── index.html 

당신은 방법으로 이미지를 참조해야합니다

background-image: url("../img/first.png"); 
+0

감사 마치에이 Walkowiak가 작동 –