Commit 95e6726a by Patryk Czarnik

Historia działań JSON

parent eb1a7b45
package com.example.demo;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HistoriaJSON {
@Autowired
private LogikaKalkulatora logika;
@GetMapping("/historia.json")
@ResponseBody
public List<String> pokazHistorie() {
// Wynik tej metody powinien zostać odesłany do klienta, nie używamy tu szablonu.
// Można to zapewnić adnotacją @ResponseBody
return logika.getHistoriaDzialan();
}
}
...@@ -30,6 +30,7 @@ https://www.baeldung.com/thymeleaf-select-option ...@@ -30,6 +30,7 @@ https://www.baeldung.com/thymeleaf-select-option
</div> </div>
<div><a th:href="@{/kalkulator/historia}">historia działań</a></div> <div><a th:href="@{/kalkulator/historia}">historia działań</a></div>
<div><a th:href="@{/historia.json}">historia JSON</a></div>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment