Commit 0125c32c by Patryk Czarnik

Przykład JS - początek

parent cf669e3a
......@@ -16,7 +16,7 @@ public class ProductController_v0 {
@ResponseBody
public String readAll() {
StringBuilder sb = new StringBuilder("Lista produktów:\n");
try(Connection c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/sklep", "kurs", "abc123");
try(Connection c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/sklep", "alx", "abc123");
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM products ORDER BY product_id")) {
......
......@@ -35,4 +35,10 @@ public class RootController {
}
return "whoami";
}
@GetMapping("/skrypt")
public String wykonajSkrypt() {
return "wykonaj_skrypt";
}
}
......@@ -36,9 +36,9 @@ public class SecurityConfig {
.authorizeHttpRequests(authz -> authz
// zezwalamy na działanie przekierowań wewnętrznych (szablony) i błędów
.dispatcherTypeMatchers(DispatcherType.FORWARD, DispatcherType.ERROR).permitAll()
.requestMatchers("/", "/hello", "/czas").permitAll()
.requestMatchers("/", "/hello", "/czas", "/skrypt").permitAll()
.requestMatchers(mvc.pattern("/whoami")).permitAll()
.requestMatchers(mvc.pattern("/*.css")).permitAll()
.requestMatchers("/*.css", "/*.js").permitAll()
.requestMatchers(mvc.pattern("/alt?/**")).authenticated() // zalogowany jako ktokolwiek
// kolejność reguł ma znaczenie - pierwsza reguła, do której pasuje zapytanie, jest decydująca
// np. /products/new wymaga uprawnień managera, chociaż to zapytanie pasowałoby te z do /products/**
......
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<script src="jquery-3.7.1.min.js"></script>
<script>
$(document).ready(function(event) {
alert("Start")
})
</script>
</head>
<body>
<h1>Stronka ze skryptem</h1>
</body>
</html>
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