Commit 1a485376 by Patryk Czarnik

przykładu użycia Spring Security Tags

parent 205094b0
......@@ -66,6 +66,10 @@
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
</dependency>
</dependencies>
<build>
......
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<html>
<head>
......@@ -19,7 +20,11 @@
<tr><th>Adres:</th><td>${customer.address}</td></tr>
<tr><th>Miasto:</th><td>${customer.postalCode} ${customer.city}</td></tr>
</table>
<c:url var="adres_do_edycji" value="/customers/${customer.customerEmail}/edit"/>
<div class="action"><a href="${adres_edycji}">Edytuj</a></div>
<sec:authorize access="hasRole('manager')">
<c:url var="adres_do_edycji" value="/customers/${customer.customerEmail}/edit"/>
<div class="action"><a href="${adres_edycji}">Edytuj</a></div>
</sec:authorize>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<%-- W tym pliku używam tagów c:url do generowania adresów, które są poprawne niezależnie od miejsca zdeployowania aplikacji.
Obojętnie, czy aplikacja działabezpośrednio pod adresem localhost:8080/ , czy w jakimś podkatalogu (ma niepusty "context-path"),
......@@ -28,13 +29,19 @@ Obojętnie, czy aplikacja działabezpośrednio pod adresem localhost:8080/ , czy
<td>${customer.address}</td>
<td>${customer.postalCode} ${customer.city}</td>
<c:url var="adres_do_edycji" value="/customers/${customer.customerEmail}/edit"/>
<td class="action"><a href="${adres_do_edycji}">Edytuj</a></td>
<td>
<sec:authorize access="hasRole('manager')">
<c:url var="adres_do_edycji" value="/customers/${customer.customerEmail}/edit"/>
<div class="action"><a href="${adres_do_edycji}">Edytuj</a></div>
</sec:authorize>
</td>
</tr>
</c:forEach>
</table>
<sec:authorize access="hasRole('manager')">
<c:url var="adres_new" value="/customers/new"/>
<div class="action"><a href="${adres_new}">Dodaj nowego klienta</a></div>
</sec:authorize>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<html>
<head>
......@@ -29,12 +30,16 @@
<p>Towar <a href="/products/${product.productId}" class="product-name">${product.productName}</a></p>
<p>Cena: <span class="product-price">${product.price}</span></p>
<p class="product-description">${product.description}</p>
<sec:authorize access="hasRole('manager')">
<div class="action"><a href="/products/${product.productId}/edit">Edytuj</a></div>
</sec:authorize>
<div class="action"><a href="/products/${product.productId}/add-to-basket">Dodaj do koszyka</a></div>
</div>
</c:forEach>
<sec:authorize access="hasRole('manager')">
<div><a href="/products/new">Dodaj nowy produkt</a></div>
</sec:authorize>
<div><a href="/">Wróć na stronę główną</a></div>
</body>
......
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