2017-05-23 1 views
0

저는 Thymeleaf가있는 SpringBoot App에서 호스팅되는 AngularJS 프로젝트에서 작업 중이며 AngularJS는 뷰와 라우팅을 통해 다른 웹 페이지의 섹션 요소를 가져와야합니다.상위 요소는 제거하지만 하위 요소는 Thymeleaf에 보관하는 방법은 무엇입니까?

그러나 ThymeLeaf가 전체 HTML 페이지 대신 섹션 요소 만 제공하도록 만드는 방법을 알아낼 수는 없지만 개발할 때 웹 페이지를 자연스러운 템플릿으로 볼 수는 있습니다.

은 그래서 서버에서이

<html> 
    <title>Don't keep this </title> 
    <body> 
     <section> 
      Keep this 
     </section> 
    </body> 
</html> 

그러나 AngularJS와 페이지를 읽을 때, Thymeleaf이이 글을 읽을 수로 저장됩니다

<section> 
    Keep this 
</section> 
+0

를 반환합니다

@RequestMapping(value = "whatever.html", method = RequestMethod.GET) public String get() { return "whatever :: section"; // Where the string 'whatever' resolves to the template, and section // resolves to the text in th:fragment. } 

? –

답변

0

그래,이 조각 꽤 간단합니다. HTML 파일은 다음과 같습니다 경우

<!-- whatever.html --> 
<html> 
    <head> 
     <title>Don't keep this </title> 
    </head> 

    <body> 
     <section th:fragment="section"> 
      Keep this 
     </section> 
    </body> 
</html> 

그리고 컨트롤러,이 같은 : 그것은 당신이 당신의 Thmeleaf 템플릿과 JS 코드를 추가 할 수있는 HTML

<section> 
    Keep this 
</section>