2017-09-24 75 views
0

我正在查看使用Spring Boot和React的以下教程。 https://spring.io/guides/tutorials/react-and-spring-data-rest/使用Spring Boot進行服務器端渲染React

由於React被渲染到Thymeleaf模板中,因此React會在這裏進行服務器端渲染嗎?對於上下文,我已經放置了下面教程中的Thymeleaf模板和React文件代碼。

的src /主/資源/模板/ index.html的

<!DOCTYPE html> 
<html xmlns:th="http://www.thymeleaf.org"> 
<head lang="en"> 
    <meta charset="UTF-8"/> 
    <title>ReactJS + Spring Data REST</title> 
    <link rel="stylesheet" href="/main.css" /> 
</head> 

<body> 

    <div id="react"></div> 

    <script src="built/bundle.js"></script> 

</body> 
</html> 

的src/main/JS/app.js - 渲染代碼

ReactDOM.render(
    <App />, 
    document.getElementById('react') 
) 

回答

1

在給出的示例反應不會被渲染服務器-側。 Thymeleaf HTML按原樣輸出。如教程中所示,通過調用Spring Boot後端中的服務設置,可以在客戶端獲取數據。

+0

謝謝,我認爲這是可能的情況,但不確定。 – Ahsan

相關問題